]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mm/damon/sysfs-schemes: fix dir put orders in access_pattern_add_dirs()
authorSeongJae Park <sj@kernel.org>
Thu, 18 Jun 2026 00:56:47 +0000 (17:56 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 2 Jul 2026 02:02:52 +0000 (19:02 -0700)
commitd58fdbe37a829fd2e5803dd4e5a72992dd8c5368
tree93611202f383734b9955f22e7cd02054967e9b1c
parente30453c61e185e914fde83c650e268067b140218
mm/damon/sysfs-schemes: fix dir put orders in access_pattern_add_dirs()

Patch series "mm/damon/sysfs-schemes: fix wrong directories put orders in
error paths".

Error paths of damon_sysfs_access_pattern_add_dirs() and
damon_sysfs_scheme_add_dirs() functions put references to directories in
wrong orders.  As a result, uninitialized memory dereference and/or
memory leak can happen.  Fix those.

This patch (of 2):

In access_pattern_add_dirs(), error handling path puts references starting
from setup failed directories.  If the failure happpened from the initial
allication in the setup functions, uninitialized memory dereference
happen.  The allocation failures will not commonly happen, but the
consequence is quite bad.  Fix the wrong reference put orders.

The issue was discovered [1] by Sashiko.

Link: https://lore.kernel.org/20260618005650.83868-2-sj@kernel.org
Link: https://lore.kernel.org/20260617060005.86852-1-sj@kernel.org
Fixes: 7e84b1f8212a ("mm/damon/sysfs: support DAMON-based Operation Schemes")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org> # 5.18.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs-schemes.c