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: 4c9ea539ad ("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>
This commit is contained in:
SeongJae Park 2025-10-03 13:14:55 -07:00 committed by Andrew Morton
parent f0c5118ebb
commit 139e7a572a
1 changed files with 2 additions and 3 deletions

View File

@ -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;
}