[PATCH] xfs: fix memory leak for data allocated by xfs_zone_gc_data_alloc()
From: Wilfred Mallawa
Date: Thu Apr 16 2026 - 22:22:43 EST
From: Wilfred Mallawa <wilfred.mallawa@xxxxxxx>
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@xxxxxxxxxxxxxxx
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@xxxxxxx>
---
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