Message ID | 8a54e85cf93d2042f1a2e29517f8f91fce56f6ab.1639135880.git.johannes.thumshirn@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: zoned: fix leak of zone_info in btrfs_get_dev_zone_info | expand |
On Fri, Dec 10, 2021 at 03:32:00AM -0800, Johannes Thumshirn wrote: > Some error paths of btrfs_get_dev_zone_info do not free zone_info, > so assign zone_info to device->zone_info as soon as we've successfully > allocated it, so it wiill get freed by the error handling. > > a411e32badc4 ("btrfs: zoned: cache reported zone during mount") As this patch is still in misc-next I'll fold the fixup, thanks.
On 10/12/2021 12:50, David Sterba wrote: > On Fri, Dec 10, 2021 at 03:32:00AM -0800, Johannes Thumshirn wrote: >> Some error paths of btrfs_get_dev_zone_info do not free zone_info, >> so assign zone_info to device->zone_info as soon as we've successfully >> allocated it, so it wiill get freed by the error handling. >> >> a411e32badc4 ("btrfs: zoned: cache reported zone during mount") > > As this patch is still in misc-next I'll fold the fixup, thanks. > Thanks
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 5e5cb9aa0569..f559d517c7c4 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -375,6 +375,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) if (!zone_info) return -ENOMEM; + device->zone_info = zone_info; + if (!bdev_is_zoned(bdev)) { if (!fs_info->zone_size) { ret = calculate_emulated_zone_size(fs_info); @@ -460,8 +462,6 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) } } - device->zone_info = zone_info; - /* Get zones type */ nactive = 0; while (sector < nr_sectors) {
Some error paths of btrfs_get_dev_zone_info do not free zone_info, so assign zone_info to device->zone_info as soon as we've successfully allocated it, so it wiill get freed by the error handling. a411e32badc4 ("btrfs: zoned: cache reported zone during mount") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/btrfs/zoned.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)