This is a note to let you know that I've just added the patch titled mm/damon/sysfs-schemes: handle tried region directory allocation failure to the 6.6-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-region-directory-allocation-failure.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From ae636ae2bbfd9279f5681dbf320d1da817e52b68 Mon Sep 17 00:00:00 2001 From: SeongJae Park <sj@xxxxxxxxxx> Date: Mon, 6 Nov 2023 23:34:08 +0000 Subject: mm/damon/sysfs-schemes: handle tried region directory allocation failure From: SeongJae Park <sj@xxxxxxxxxx> commit ae636ae2bbfd9279f5681dbf320d1da817e52b68 upstream. DAMON sysfs interface's before_damos_apply callback (damon_sysfs_before_damos_apply()), which creates the DAMOS tried regions for each DAMOS action applied region, is not handling the allocation failure for the sysfs directory data. As a result, NULL pointer derefeence is possible. Fix it by handling the case. Link: https://lkml.kernel.org/r/20231106233408.51159-4-sj@xxxxxxxxxx Fixes: f1d13cacabe1 ("mm/damon/sysfs: implement DAMOS tried regions update command") 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 | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1752,6 +1752,8 @@ static int damon_sysfs_before_damos_appl return 0; region = damon_sysfs_scheme_region_alloc(r); + if (!region) + return 0; list_add_tail(®ion->list, &sysfs_regions->regions_list); sysfs_regions->nr_regions++; if (kobject_init_and_add(®ion->kobj, Patches currently in stable-queue which might be from sj@xxxxxxxxxx are queue-6.6/mm-damon-implement-a-function-for-max-nr_accesses-safe-calculation.patch queue-6.6/mm-damon-ops-common-avoid-divide-by-zero-during-region-hotness-calculation.patch queue-6.6/mm-damon-sysfs-check-error-from-damon_sysfs_update_target.patch queue-6.6/mm-damon-lru_sort-avoid-divide-by-zero-in-hot-threshold-calculation.patch queue-6.6/mm-damon-core-avoid-divide-by-zero-during-monitoring-results-update.patch queue-6.6/mm-damon-sysfs-schemes-handle-tried-region-directory-allocation-failure.patch queue-6.6/mm-damon-sysfs-update-monitoring-target-regions-for-online-input-commit.patch queue-6.6/mm-damon-sysfs-schemes-handle-tried-regions-sysfs-directory-allocation-failure.patch queue-6.6/mm-damon-sysfs-remove-requested-targets-when-online-commit-inputs.patch queue-6.6/mm-damon-core.c-avoid-unintentional-filtering-out-of-schemes.patch