btrfs: fix a memory leak in read_zone_info
PATCH 1/1 btrfs: fix a memory leak in read_zone_info
Don't leak the bioc on normal completion.
--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/zoned.c +1 -1
@@ -1759,7 +1759,7 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,break ; }memalloc_nofs_restore (nofs_flag); - +btrfs_put_bioc (bioc);return ret; }
Signature · 1 line
2.30.2
Looks good,
Quoted 13 lines · Christoph Hellwig
Don't leak the bioc on normal completion.
Fixes 7db1c5d14dcd ("btrfs: zoned: support dev-replace in zoned filesystems")Signed-off-by Christoph Hellwig <[email protected]>--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/zoned.c +0
-0
fs/btrfs/zoned.c static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical, · line 1765
Quoted 8 lines
fs/btrfs/zoned.c +1
-1@@ -1759,7 +1759,7 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,break ; }memalloc_nofs_restore (nofs_flag); - +btrfs_put_bioc (bioc);return ret; }
Why not call put also during return -EINVAL a few lines above?
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
return -EINVAL;
-Anand
Quoted 25 lines · Anand Jain
Quoted 13 lines · Christoph Hellwig
Don't leak the bioc on normal completion.
Fixes 7db1c5d14dcd ("btrfs: zoned: support dev-replace in zoned filesystems")Signed-off-by Christoph Hellwig <[email protected]>--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/zoned.c +0
-0fs/btrfs/zoned.c static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical, · line 1765
Quoted 8 lines
fs/btrfs/zoned.c +1
-1@@ -1759,7 +1759,7 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,break ; }memalloc_nofs_restore (nofs_flag); - +btrfs_put_bioc (bioc);return ret; }Why not call put also during return
-EINVALa few lines above?
Quoted 2 lines
if (
bioc->map_type&BTRFS_BLOCK_GROUP_RAID56_MASK)return -EINVAL;
Actually yes, it should be here as well, otherwise this would leak. RAID56 + zoned combination is rejected much earlier so this would not happen in practice.
Quoted 3 lines · David Sterba
Actually yes, it should be here as well, otherwise this would leak. RAID56 + zoned combination is rejected much earlier so this would not happen in practice.
A version with that fixed is already out on the list, just pick that one up instead.
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · David Sterba
Actually yes, it should be here as well, otherwise this would leak. RAID56 + zoned combination is rejected much earlier so this would not happen in practice.
A version with that fixed is already out on the list, just pick that one up instead.
Right, I did not notice it.
Quoted 4 lines · Christoph Hellwig
Don't leak the bioc on normal completion.
Fixes 7db1c5d14dcd ("btrfs: zoned: support dev-replace in zoned filesystems")Signed-off-by Christoph Hellwig <[email protected]>
Added to misc-next, thanks.