[PATCH v2 1/1] mm/damon/reclaim: fix potential memory leak

From: yahia

Date: Fri Jun 19 2026 - 20:36:36 EST


Signed-off-by: yahia <yahia.a.abdrabou@xxxxxxxxx>
---
mm/damon/reclaim.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
index ce4499cf4b8b..6601b08996c6 100644
--- a/mm/damon/reclaim.c
+++ b/mm/damon/reclaim.c
@@ -478,6 +478,11 @@ static int __init damon_reclaim_init(void)
out:
if (err && enabled)
enabled = false;
+
+ if (err && ctx) {
+ damon_destroy_ctx(ctx);
+ ctx = NULL;
+ }
return err;
}

--
2.54.0