* [PATCH] xfs: fix memory leak on error in xfs_alloc_zone_info()
@ 2026-04-14 3:41 Wilfred Mallawa
2026-04-14 3:58 ` Damien Le Moal
2026-04-14 10:43 ` Carlos Maiolino
0 siblings, 2 replies; 3+ messages in thread
From: Wilfred Mallawa @ 2026-04-14 3:41 UTC (permalink / raw)
To: linux-xfs, linux-kernel
Cc: Damien Le Moal, Alistair Francis, Carlos Maiolino, Hans Holmberg,
Darrick J . Wong, Christoph Hellwig, Wilfred Mallawa, stable
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 this while loop used
in xfs_alloc_zone_info(). Fix it by allowing for the i == 0 case to be covered.
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
Cc: stable@vger.kernel.org
---
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;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] xfs: fix memory leak on error in xfs_alloc_zone_info()
2026-04-14 3:41 [PATCH] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
@ 2026-04-14 3:58 ` Damien Le Moal
2026-04-14 10:43 ` Carlos Maiolino
1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2026-04-14 3:58 UTC (permalink / raw)
To: Wilfred Mallawa, linux-xfs, linux-kernel
Cc: Alistair Francis, Carlos Maiolino, Hans Holmberg,
Darrick J . Wong, Christoph Hellwig, Wilfred Mallawa, stable
On 2026/04/14 5:41, 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 this while loop used
s/this/the
> in xfs_alloc_zone_info(). Fix it by allowing for the i == 0 case to be covered.
Please limit your commit message text to 74 chars per line.
(See Documentation/process/submitting-patches.rst, "The canonical patch format"
section).
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
I think that the usual order here is to have the Fixes and CC tag before your
signed-off-by.
> Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
> Cc: stable@vger.kernel.org
Other than this, looks good to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> 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;
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xfs: fix memory leak on error in xfs_alloc_zone_info()
2026-04-14 3:41 [PATCH] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
2026-04-14 3:58 ` Damien Le Moal
@ 2026-04-14 10:43 ` Carlos Maiolino
1 sibling, 0 replies; 3+ messages in thread
From: Carlos Maiolino @ 2026-04-14 10:43 UTC (permalink / raw)
To: Wilfred Mallawa
Cc: linux-xfs, linux-kernel, Damien Le Moal, Alistair Francis,
Hans Holmberg, Darrick J . Wong, Christoph Hellwig,
Wilfred Mallawa, stable
On Tue, Apr 14, 2026 at 01:41:51PM +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 this while loop used
> in xfs_alloc_zone_info(). Fix it by allowing for the i == 0 case to be covered.
>
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
> Cc: stable@vger.kernel.org
Code looks good.
After fixing Damien's suggestions, feel free to add:
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.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;
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-14 10:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 3:41 [PATCH] xfs: fix memory leak on error in xfs_alloc_zone_info() Wilfred Mallawa
2026-04-14 3:58 ` Damien Le Moal
2026-04-14 10:43 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox