diff options
| author | SeongJae Park <sj@kernel.org> | 2026-05-28 17:01:03 -0700 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-05-28 21:30:16 -0700 |
| commit | d90fdc074685684dfc210e86688cb009c1a327a7 (patch) | |
| tree | 67c08d61f3e892d4a9149b8aea4a60cdd51f726b /mm | |
| parent | 1b3e7645378b14879d3280b1ce31743e2e901eb2 (diff) | |
| download | linux-next-history-d90fdc074685684dfc210e86688cb009c1a327a7.tar.gz | |
mm/damon/lru_sort: handle ctx allocation failure
DAMON_LRU_SORT allocates the damon_ctx object for its kdamond in its init
function. damon_lru_sort_enabled_store() wrongly assumes the allocation
will always succeed once tried. If the damon_ctx allocation was failed,
therefore, code execution reaches to damon_commit_ctx() while 'ctx' is
NULL. As a result, it dereferences the NULL 'ctx' pointer. Avoid the
NULL dereference by returning -ENOMEM if 'ctx' is NULL.
Link: https://lore.kernel.org/20260529000104.7006-3-sj@kernel.org
Fixes: c4a8e662c839 ("mm/damon/lru_sort: use damon_initialized()")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org> # 6.18.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/damon/lru_sort.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 8494040b1ee48..8cfe7bd3dc1d3 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -437,6 +437,10 @@ static int damon_lru_sort_enabled_store(const char *val, if (!damon_initialized()) return 0; + /* damon_modules_new_paddr_ctx_target() in the init function failed. */ + if (!ctx) + return -ENOMEM; + return damon_lru_sort_turn(enabled); } |
