* [PATCH] btrfs: zoned: fix leak of zone_info in btrfs_get_dev_zone_info
@ 2021-12-10 11:32 Johannes Thumshirn
2021-12-10 11:44 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2021-12-10 11:32 UTC (permalink / raw)
To: David Sterba
Cc: Johannes Thumshirn, Dan Carpenter, linux-btrfs, kernel test robot
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(-)
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) {
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: zoned: fix leak of zone_info in btrfs_get_dev_zone_info
2021-12-10 11:32 [PATCH] btrfs: zoned: fix leak of zone_info in btrfs_get_dev_zone_info Johannes Thumshirn
@ 2021-12-10 11:44 ` David Sterba
2021-12-10 13:34 ` Johannes Thumshirn
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2021-12-10 11:44 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: David Sterba, Dan Carpenter, linux-btrfs, kernel test robot
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: zoned: fix leak of zone_info in btrfs_get_dev_zone_info
2021-12-10 11:44 ` David Sterba
@ 2021-12-10 13:34 ` Johannes Thumshirn
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2021-12-10 13:34 UTC (permalink / raw)
To: dsterba; +Cc: David Sterba, Dan Carpenter, linux-btrfs, kernel test robot
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-10 13:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 11:32 [PATCH] btrfs: zoned: fix leak of zone_info in btrfs_get_dev_zone_info Johannes Thumshirn
2021-12-10 11:44 ` David Sterba
2021-12-10 13:34 ` Johannes Thumshirn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.