This is a note to let you know that I've just added the patch titled btrfs: zoned: fix a leaked bioc in read_zone_info to the 5.18-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-zoned-fix-a-leaked-bioc-in-read_zone_info.patch and it can be found in the queue-5.18 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 2963457829decf0c824a443238d251151ed18ff5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@xxxxxx> Date: Thu, 30 Jun 2022 18:03:19 +0200 Subject: btrfs: zoned: fix a leaked bioc in read_zone_info From: Christoph Hellwig <hch@xxxxxx> 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@xxxxxxxxxxxxxxx # 5.16+ Reviewed-by: Anand Jain <anand.jain@xxxxxxxxxx> Signed-off-by: Christoph Hellwig <hch@xxxxxx> [ update changelog ] Reviewed-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/zoned.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1727,12 +1727,14 @@ static int read_zone_info(struct btrfs_f 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_f break; } memalloc_nofs_restore(nofs_flag); - +out_put_bioc: + btrfs_put_bioc(bioc); return ret; } Patches currently in stable-queue which might be from hch@xxxxxx are queue-5.18/btrfs-return-eagain-for-nowait-dio-reads-writes-on-compressed-and-inline-extents.patch queue-5.18/sh-convert-nommu-io-re-un-map-to-static-inline-functions.patch queue-5.18/btrfs-zoned-fix-a-leaked-bioc-in-read_zone_info.patch