Skip to content

Commit 139e7a5

Browse files
sjp38akpm00
authored andcommitted
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: 4c9ea53 ("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>
1 parent f0c5118 commit 139e7a5

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

mm/damon/sysfs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,12 +1476,11 @@ static int damon_sysfs_commit_input(void *data)
14761476
if (!test_ctx)
14771477
return -ENOMEM;
14781478
err = damon_commit_ctx(test_ctx, param_ctx);
1479-
if (err) {
1480-
damon_destroy_ctx(test_ctx);
1479+
if (err)
14811480
goto out;
1482-
}
14831481
err = damon_commit_ctx(kdamond->damon_ctx, param_ctx);
14841482
out:
1483+
damon_destroy_ctx(test_ctx);
14851484
damon_destroy_ctx(param_ctx);
14861485
return err;
14871486
}

0 commit comments

Comments
 (0)