summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-06-30 18:03:19 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-22 10:21:21 +0200
commit02fc3a6ed7873e85c037ea9b67614780713966d7 (patch)
treea85e795f867c2ff65a4a43464a238a42dc201b47 /fs
parent722ab9a4632bbf6dcc93aee03d7a121ac85d7f4c (diff)
downloadlinux-02fc3a6ed7873e85c037ea9b67614780713966d7.tar.gz
linux-02fc3a6ed7873e85c037ea9b67614780713966d7.tar.bz2
linux-02fc3a6ed7873e85c037ea9b67614780713966d7.zip
btrfs: zoned: fix a leaked bioc in read_zone_info
commit 2963457829decf0c824a443238d251151ed18ff5 upstream. The bioc would leak on the normal completion path and also on the RAID56 check (but that one won't happen in practice due to the invalid combination with zoned mode). Fixes: 7db1c5d14dcd ("btrfs: zoned: support dev-replace in zoned filesystems") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de> [ update changelog ] Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/zoned.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index b5236f5afca7..5091d679a602 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1727,12 +1727,14 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
ret = btrfs_map_sblock(fs_info, BTRFS_MAP_GET_READ_MIRRORS, logical,
&mapped_length, &bioc);
if (ret || !bioc || mapped_length < PAGE_SIZE) {
- btrfs_put_bioc(bioc);
- return -EIO;
+ ret = -EIO;
+ goto out_put_bioc;
}
- if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
- return -EINVAL;
+ if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
+ ret = -EINVAL;
+ goto out_put_bioc;
+ }
nofs_flag = memalloc_nofs_save();
nmirrors = (int)bioc->num_stripes;
@@ -1751,7 +1753,8 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
break;
}
memalloc_nofs_restore(nofs_flag);
-
+out_put_bioc:
+ btrfs_put_bioc(bioc);
return ret;
}