summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2025-10-03 13:14:55 -0700
committerAndrew Morton <akpm@linux-foundation.org>2025-10-15 13:24:33 -0700
commit139e7a572af0b45f558b5e502121a768dc328ba8 (patch)
tree94394b7ff0592eb6fec2d8e6a92c3c6d5364e93c
parentf0c5118ebb0eb7e4fd6f0d2ace3315ca141b317f (diff)
mm/damon/sysfs: dealloc commit test ctx always
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 <sj@kernel.org> Cc: <stable@vger.kernel.org> [6.15+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/damon/sysfs.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 703f55a91b3c..cd6815ecc04e 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1476,12 +1476,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;
}