From: SeongJae Park Date: Fri, 3 Oct 2025 20:14:55 +0000 (-0700) Subject: mm/damon/sysfs: dealloc commit test ctx always X-Git-Tag: v6.17.6~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba236520ae53418859f4b7c7de3c71478d3c0b5a;p=thirdparty%2Fkernel%2Fstable.git mm/damon/sysfs: dealloc commit test ctx always commit 139e7a572af0b45f558b5e502121a768dc328ba8 upstream. The damon_ctx for testing online DAMON parameters commit inputs is deallocated only when the test fails. This means memory is leaked for every successful online DAMON parameters commit. Fix the leak by always deallocating it. Link: https://lkml.kernel.org/r/20251003201455.41448-3-sj@kernel.org Fixes: 4c9ea539ad59 ("mm/damon/sysfs: validate user inputs from damon_sysfs_commit_input()") Signed-off-by: SeongJae Park Cc: [6.15+] Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 5a4c0a2067b25..2959beb4bcbfd 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1438,12 +1438,11 @@ static int damon_sysfs_commit_input(void *data) if (!test_ctx) return -ENOMEM; err = damon_commit_ctx(test_ctx, param_ctx); - if (err) { - damon_destroy_ctx(test_ctx); + if (err) goto out; - } err = damon_commit_ctx(kdamond->damon_ctx, param_ctx); out: + damon_destroy_ctx(test_ctx); damon_destroy_ctx(param_ctx); return err; }