[PATCH 2/2] mm/damon/reclaim: fix potential memory leak
From: yahia
Date: Fri Jun 19 2026 - 19:46:43 EST
From: yahia ahmed <yahia.a.abdrabou@xxxxxxxxx>
Fix a potential memory leak if initialization encounters
an error, ctx won't be destroyed.
Signed-off-by: yahia ahmed <yahia.a.abdrabou@xxxxxxxxx>
---
mm/damon/reclaim.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
index 15bc06ae7505..dfe52717d92c 100644
--- a/mm/damon/reclaim.c
+++ b/mm/damon/reclaim.c
@@ -481,6 +481,10 @@ static int __init damon_reclaim_init(void)
out:
if (err && enabled)
enabled = false;
+
+ /* Prevent potenial memory leakage */
+ if (err && ctx)
+ damon_destroy_ctx(ctx);
return err;
}
--
2.54.0