Commit f1a07c2b authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: zoned: fix memory leak after finding block group with super blocks

At exclude_super_stripes(), if we happen to find a block group that has
super blocks mapped to it and we are on a zoned filesystem, we error out
as this is not supposed to happen, indicating either a bug or maybe some
memory corruption for example. However we are exiting the function without
freeing the memory allocated for the logical address of the super blocks.
Fix this by freeing the logical address.

Fixes: 12659251 ("btrfs: implement log-structured superblock for ZONED mode")
CC: stable@vger.kernel.org # 5.10+
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0657b20c
...@@ -2088,6 +2088,7 @@ static int exclude_super_stripes(struct btrfs_block_group *cache) ...@@ -2088,6 +2088,7 @@ static int exclude_super_stripes(struct btrfs_block_group *cache)
/* Shouldn't have super stripes in sequential zones */ /* Shouldn't have super stripes in sequential zones */
if (zoned && nr) { if (zoned && nr) {
kfree(logical);
btrfs_err(fs_info, btrfs_err(fs_info,
"zoned: block group %llu must not contain super block", "zoned: block group %llu must not contain super block",
cache->start); cache->start);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment