public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc()
@ 2026-04-17  2:16 Wilfred Mallawa
  2026-04-17  7:51 ` Christoph Hellwig
  2026-04-17 14:18 ` Darrick J. Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Wilfred Mallawa @ 2026-04-17  2:16 UTC (permalink / raw)
  To: linux-xfs, linux-kernel
  Cc: Carlos Maiolino, Hans Holmberg, Darrick J . Wong, Wilfred Mallawa,
	stable

From: Wilfred Mallawa <wilfred.mallawa@wdc.com>

In xfs_zone_gc_mount(), on error, a struct xfs_zone_gc_data allocated
with xfs_zone_gc_data_alloc() is freed with kfree(), however, this
doesn't free the underlying folios or the rmap_irecs.

Use xfs_zone_gc_data_free() to correctly free this memory.

Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection")
Cc: stable@vger.kernel.org
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
---
 fs/xfs/xfs_zone_gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index e7b33d5a8b3d..2520e57e24a8 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -1230,7 +1230,7 @@ xfs_zone_gc_mount(
 	if (data->oz)
 		xfs_open_zone_put(data->oz);
 out_free_gc_data:
-	kfree(data);
+	xfs_zone_gc_data_free(data);
 	return error;
 }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc()
  2026-04-17  2:16 [PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc() Wilfred Mallawa
@ 2026-04-17  7:51 ` Christoph Hellwig
  2026-04-17 14:18 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-04-17  7:51 UTC (permalink / raw)
  To: Wilfred Mallawa
  Cc: linux-xfs, linux-kernel, Carlos Maiolino, Hans Holmberg,
	Darrick J . Wong, Wilfred Mallawa, stable

On Fri, Apr 17, 2026 at 12:16:30PM +1000, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> 
> In xfs_zone_gc_mount(), on error, a struct xfs_zone_gc_data allocated
> with xfs_zone_gc_data_alloc() is freed with kfree(), however, this
> doesn't free the underlying folios or the rmap_irecs.
> 
> Use xfs_zone_gc_data_free() to correctly free this memory.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc()
  2026-04-17  2:16 [PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc() Wilfred Mallawa
  2026-04-17  7:51 ` Christoph Hellwig
@ 2026-04-17 14:18 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2026-04-17 14:18 UTC (permalink / raw)
  To: Wilfred Mallawa
  Cc: linux-xfs, linux-kernel, Carlos Maiolino, Hans Holmberg,
	Wilfred Mallawa, stable

On Fri, Apr 17, 2026 at 12:16:30PM +1000, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> 
> In xfs_zone_gc_mount(), on error, a struct xfs_zone_gc_data allocated
> with xfs_zone_gc_data_alloc() is freed with kfree(), however, this
> doesn't free the underlying folios or the rmap_irecs.
> 
> Use xfs_zone_gc_data_free() to correctly free this memory.
> 
> 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: "Darrick J. Wong" <djwong@kernel.org>

--D

> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---
>  fs/xfs/xfs_zone_gc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
> index e7b33d5a8b3d..2520e57e24a8 100644
> --- a/fs/xfs/xfs_zone_gc.c
> +++ b/fs/xfs/xfs_zone_gc.c
> @@ -1230,7 +1230,7 @@ xfs_zone_gc_mount(
>  	if (data->oz)
>  		xfs_open_zone_put(data->oz);
>  out_free_gc_data:
> -	kfree(data);
> +	xfs_zone_gc_data_free(data);
>  	return error;
>  }
>  
> -- 
> 2.53.0
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-17 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17  2:16 [PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc() Wilfred Mallawa
2026-04-17  7:51 ` Christoph Hellwig
2026-04-17 14:18 ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox