summaryrefslogtreecommitdiff
path: root/mm/damon
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2025-10-03 13:14:54 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 14:10:25 +0100
commit5b3609d9b9650bdea0bfdf643e0ce57e1aed67fc (patch)
tree3ad876cf927639fa72f700a8db5f7a96eed15d4e /mm/damon
parentff8dcf621a4172f4a6d42cbbb25d21659d3ac300 (diff)
downloadlinux-5b3609d9b9650bdea0bfdf643e0ce57e1aed67fc.tar.gz
linux-5b3609d9b9650bdea0bfdf643e0ce57e1aed67fc.tar.bz2
linux-5b3609d9b9650bdea0bfdf643e0ce57e1aed67fc.zip
mm/damon/sysfs: catch commit test ctx alloc failure
commit f0c5118ebb0eb7e4fd6f0d2ace3315ca141b317f upstream. 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: 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/damon')
-rw-r--r--mm/damon/sysfs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 7308dee97b21..5a4c0a2067b2 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1435,6 +1435,8 @@ static int damon_sysfs_commit_input(void *data)
if (IS_ERR(param_ctx))
return PTR_ERR(param_ctx);
test_ctx = damon_new_ctx();
+ if (!test_ctx)
+ return -ENOMEM;
err = damon_commit_ctx(test_ctx, param_ctx);
if (err) {
damon_destroy_ctx(test_ctx);