Skip to content

Commit f0c5118

Browse files
sjp38akpm00
authored andcommitted
mm/damon/sysfs: catch commit test ctx alloc failure
Patch series "mm/damon/sysfs: fix commit test damon_ctx [de]allocation". DAMON sysfs interface dynamically allocates and uses a damon_ctx object for testing if given inputs for online DAMON parameters update is valid. The object is being used without an allocation failure check, and leaked when the test succeeds. Fix the two bugs. This patch (of 2): The damon_ctx for testing online DAMON parameters commit inputs is used without its allocation failure check. This could result in an invalid memory access. Fix it by directly returning an error when the allocation failed. Link: https://lkml.kernel.org/r/20251003201455.41448-1-sj@kernel.org Link: https://lkml.kernel.org/r/20251003201455.41448-2-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 c97513c commit f0c5118

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

mm/damon/sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,8 @@ static int damon_sysfs_commit_input(void *data)
14731473
if (IS_ERR(param_ctx))
14741474
return PTR_ERR(param_ctx);
14751475
test_ctx = damon_new_ctx();
1476+
if (!test_ctx)
1477+
return -ENOMEM;
14761478
err = damon_commit_ctx(test_ctx, param_ctx);
14771479
if (err) {
14781480
damon_destroy_ctx(test_ctx);

0 commit comments

Comments
 (0)