This is a note to let you know that I've just added the patch titled mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure to the 6.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-damon-sysfs-schemes-handle-tried-regions-sysfs-directory-allocation-failure.patch and it can be found in the queue-6.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 84055688b6bc075c92a88e2d6c3ad26ab93919f9 Mon Sep 17 00:00:00 2001 From: SeongJae Park <sj@xxxxxxxxxx> Date: Mon, 6 Nov 2023 23:34:07 +0000 Subject: mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure From: SeongJae Park <sj@xxxxxxxxxx> commit 84055688b6bc075c92a88e2d6c3ad26ab93919f9 upstream. DAMOS tried regions sysfs directory allocation function (damon_sysfs_scheme_regions_alloc()) is not handling the memory allocation failure. In the case, the code will dereference NULL pointer. Handle the failure to avoid such invalid access. Link: https://lkml.kernel.org/r/20231106233408.51159-3-sj@xxxxxxxxxx Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory") Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> [6.2+] Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/damon/sysfs-schemes.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -125,6 +125,9 @@ damon_sysfs_scheme_regions_alloc(void) struct damon_sysfs_scheme_regions *regions = kmalloc(sizeof(*regions), GFP_KERNEL); + if (!regions) + return NULL; + regions->kobj = (struct kobject){}; INIT_LIST_HEAD(®ions->regions_list); regions->nr_regions = 0; Patches currently in stable-queue which might be from sj@xxxxxxxxxx are queue-6.5/mm-damon-implement-a-function-for-max-nr_accesses-safe-calculation.patch queue-6.5/mm-damon-ops-common-avoid-divide-by-zero-during-region-hotness-calculation.patch queue-6.5/mm-damon-sysfs-check-error-from-damon_sysfs_update_target.patch queue-6.5/mm-damon-lru_sort-avoid-divide-by-zero-in-hot-threshold-calculation.patch queue-6.5/mm-damon-core-avoid-divide-by-zero-during-monitoring-results-update.patch queue-6.5/mm-damon-sysfs-schemes-handle-tried-region-directory-allocation-failure.patch queue-6.5/mm-damon-sysfs-update-monitoring-target-regions-for-online-input-commit.patch queue-6.5/mm-damon-sysfs-schemes-handle-tried-regions-sysfs-directory-allocation-failure.patch queue-6.5/mm-damon-sysfs-remove-requested-targets-when-online-commit-inputs.patch