btrfs: zoned: fix a leaked bioc in read_zone_info
[ Upstream commit 2963457829decf0c824a443238d251151ed18ff5 ]
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: 7db1c5d14d ("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: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d2faf8ed1d
commit
d300ced128
@@ -1511,12 +1511,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,
|
ret = btrfs_map_sblock(fs_info, BTRFS_MAP_GET_READ_MIRRORS, logical,
|
||||||
&mapped_length, &bioc);
|
&mapped_length, &bioc);
|
||||||
if (ret || !bioc || mapped_length < PAGE_SIZE) {
|
if (ret || !bioc || mapped_length < PAGE_SIZE) {
|
||||||
btrfs_put_bioc(bioc);
|
ret = -EIO;
|
||||||
return -EIO;
|
goto out_put_bioc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
|
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto out_put_bioc;
|
||||||
|
}
|
||||||
|
|
||||||
nofs_flag = memalloc_nofs_save();
|
nofs_flag = memalloc_nofs_save();
|
||||||
nmirrors = (int)bioc->num_stripes;
|
nmirrors = (int)bioc->num_stripes;
|
||||||
@@ -1535,7 +1537,8 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memalloc_nofs_restore(nofs_flag);
|
memalloc_nofs_restore(nofs_flag);
|
||||||
|
out_put_bioc:
|
||||||
|
btrfs_put_bioc(bioc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user