mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
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 [1]
Fixes: 7e84b1f821 ("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>
This commit is contained in:
parent
e30453c61e
commit
d58fdbe37a
|
|
@ -1993,22 +1993,19 @@ static int damon_sysfs_access_pattern_add_dirs(
|
|||
err = damon_sysfs_access_pattern_add_range_dir(access_pattern,
|
||||
&access_pattern->sz, "sz");
|
||||
if (err)
|
||||
goto put_sz_out;
|
||||
return err;
|
||||
|
||||
err = damon_sysfs_access_pattern_add_range_dir(access_pattern,
|
||||
&access_pattern->nr_accesses, "nr_accesses");
|
||||
if (err)
|
||||
goto put_nr_accesses_sz_out;
|
||||
goto put_sz_out;
|
||||
|
||||
err = damon_sysfs_access_pattern_add_range_dir(access_pattern,
|
||||
&access_pattern->age, "age");
|
||||
if (err)
|
||||
goto put_age_nr_accesses_sz_out;
|
||||
goto put_nr_accesses_sz_out;
|
||||
return 0;
|
||||
|
||||
put_age_nr_accesses_sz_out:
|
||||
kobject_put(&access_pattern->age->kobj);
|
||||
access_pattern->age = NULL;
|
||||
put_nr_accesses_sz_out:
|
||||
kobject_put(&access_pattern->nr_accesses->kobj);
|
||||
access_pattern->nr_accesses = NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user