Skip to content

Commit 2963457

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: zoned: fix a leaked bioc in read_zone_info
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: 7db1c5d ("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>
1 parent a4527e1 commit 2963457

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

fs/btrfs/zoned.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,12 +1736,14 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
17361736
ret = btrfs_map_sblock(fs_info, BTRFS_MAP_GET_READ_MIRRORS, logical,
17371737
&mapped_length, &bioc);
17381738
if (ret || !bioc || mapped_length < PAGE_SIZE) {
1739-
btrfs_put_bioc(bioc);
1740-
return -EIO;
1739+
ret = -EIO;
1740+
goto out_put_bioc;
17411741
}
17421742

1743-
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
1744-
return -EINVAL;
1743+
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
1744+
ret = -EINVAL;
1745+
goto out_put_bioc;
1746+
}
17451747

17461748
nofs_flag = memalloc_nofs_save();
17471749
nmirrors = (int)bioc->num_stripes;
@@ -1760,7 +1762,8 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
17601762
break;
17611763
}
17621764
memalloc_nofs_restore(nofs_flag);
1763-
1765+
out_put_bioc:
1766+
btrfs_put_bioc(bioc);
17641767
return ret;
17651768
}
17661769

0 commit comments

Comments
 (0)