]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group()
authorQu Wenruo <wqu@suse.com>
Thu, 10 Oct 2019 02:39:26 +0000 (10:39 +0800)
committerDavid Sterba <dsterba@suse.com>
Fri, 11 Oct 2019 19:27:51 +0000 (21:27 +0200)
In btrfs_read_block_groups(), if we have an invalid block group which
has mixed type (DATA|METADATA) while the fs doesn't have MIXED_GROUPS
feature, we error out without freeing the block group cache.

This patch will add the missing btrfs_put_block_group() to prevent
memory leak.

Note for stable backports: the file to patch in versions <= 5.3 is
fs/btrfs/extent-tree.c

Fixes: 49303381f19a ("Btrfs: bail out if block group has different mixed flag")
CC: stable@vger.kernel.org # 4.9+
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c

index bf7e3f23bba745528f863066c4d0be5224d8d2e1..670700cb1110692c2fc9e763f6ae028654a3d35a 100644 (file)
@@ -1761,6 +1761,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                        btrfs_err(info,
 "bg %llu is a mixed block group but filesystem hasn't enabled mixed block groups",
                                  cache->key.objectid);
+                       btrfs_put_block_group(cache);
                        ret = -EINVAL;
                        goto error;
                }