* Re: [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info()
2026-04-14 23:45 [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
@ 2026-04-15 0:03 ` Darrick J. Wong
2026-04-15 5:18 ` Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2026-04-15 0:03 UTC (permalink / raw)
To: Wilfred Mallawa
Cc: linux-xfs, linux-kernel, Damien Le Moal, Alistair Francis,
Carlos Maiolino, Hans Holmberg, Christoph Hellwig,
Wilfred Mallawa, stable, Carlos Maiolino
On Wed, Apr 15, 2026 at 09:45:14AM +1000, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> Currently, the 0th index of the zi_used_bucket_bitmap array is not freed
> on error due to the pre-decrement then evaluate semantic of the while
> loop used in xfs_alloc_zone_info(). Fix it by allowing for the i == 0
> case to be covered.
>
> Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
> Cc: stable@vger.kernel.org
Cc: <stable@vger.kernel.org> # v6.15
(autobackport plz, I need all the help I can get)
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---
> fs/xfs/xfs_zone_alloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index a851b98143c0..c64f9ab743a6 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -1217,7 +1217,7 @@ xfs_alloc_zone_info(
> return zi;
>
> out_free_bitmaps:
> - while (--i > 0)
> + while (--i >= 0)
With the git trailer amended,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> kvfree(zi->zi_used_bucket_bitmap[i]);
> kfree(zi);
> return NULL;
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info()
2026-04-14 23:45 [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
2026-04-15 0:03 ` Darrick J. Wong
@ 2026-04-15 5:18 ` Christoph Hellwig
2026-04-15 13:33 ` Hans Holmberg
2026-04-27 13:26 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2026-04-15 5:18 UTC (permalink / raw)
To: Wilfred Mallawa
Cc: linux-xfs, linux-kernel, Damien Le Moal, Alistair Francis,
Carlos Maiolino, Hans Holmberg, Darrick J . Wong,
Christoph Hellwig, Wilfred Mallawa, stable, Carlos Maiolino
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info()
2026-04-14 23:45 [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
2026-04-15 0:03 ` Darrick J. Wong
2026-04-15 5:18 ` Christoph Hellwig
@ 2026-04-15 13:33 ` Hans Holmberg
2026-04-27 13:26 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Hans Holmberg @ 2026-04-15 13:33 UTC (permalink / raw)
To: Wilfred Mallawa, linux-xfs@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Damien Le Moal, Alistair Francis, Carlos Maiolino,
Darrick J . Wong, Christoph Hellwig, Wilfred Mallawa,
stable@vger.kernel.org, Carlos Maiolino
On 15/04/2026 01:46, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> Currently, the 0th index of the zi_used_bucket_bitmap array is not freed
> on error due to the pre-decrement then evaluate semantic of the while
> loop used in xfs_alloc_zone_info(). Fix it by allowing for the i == 0
> case to be covered.
>
> Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
> Cc: stable@vger.kernel.org
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---
> fs/xfs/xfs_zone_alloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index a851b98143c0..c64f9ab743a6 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -1217,7 +1217,7 @@ xfs_alloc_zone_info(
> return zi;
>
> out_free_bitmaps:
> - while (--i > 0)
> + while (--i >= 0)
> kvfree(zi->zi_used_bucket_bitmap[i]);
> kfree(zi);
> return NULL;
Thanks!
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info()
2026-04-14 23:45 [PATCH v2] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
` (2 preceding siblings ...)
2026-04-15 13:33 ` Hans Holmberg
@ 2026-04-27 13:26 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Carlos Maiolino @ 2026-04-27 13:26 UTC (permalink / raw)
To: linux-xfs, linux-kernel, Wilfred Mallawa
Cc: Damien Le Moal, Alistair Francis, Hans Holmberg, Darrick J . Wong,
Christoph Hellwig, Wilfred Mallawa, stable, Carlos Maiolino
On Wed, 15 Apr 2026 09:45:14 +1000, Wilfred Mallawa wrote:
> Currently, the 0th index of the zi_used_bucket_bitmap array is not freed
> on error due to the pre-decrement then evaluate semantic of the while
> loop used in xfs_alloc_zone_info(). Fix it by allowing for the i == 0
> case to be covered.
>
>
Applied to for-next, thanks!
[1/1] xfs: fix memory leak on error in xfs_alloc_zone_info()
commit: 592975da8c3ca87b043077e6eafa37665eae7936
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread