Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/sysfs: cleanup attrs subdirs on context dir setup failure

When a context DAMON sysfs directory setup is failed after setup of attrs/
directory, subdirectories of attrs/ directory are not cleaned up. As a
result, DAMON sysfs interface is nearly broken until the system reboots,
and the memory for the unremoved directory is leaked.

Cleanup the directories under such failures.

Link: https://lkml.kernel.org/r/20251225023043.18579-3-sj@kernel.org
Fixes: c951cd3b8901 ("mm/damon: implement a minimal stub for sysfs-based DAMON interface")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: chongjiapeng <jiapeng.chong@linux.alibaba.com>
Cc: <stable@vger.kernel.org> # 5.18.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
9814cc83 a24ca8eb

+3 -2
+3 -2
mm/damon/sysfs.c
··· 950 950 951 951 err = damon_sysfs_context_set_targets(context); 952 952 if (err) 953 - goto put_attrs_out; 953 + goto rmdir_put_attrs_out; 954 954 955 955 err = damon_sysfs_context_set_schemes(context); 956 956 if (err) ··· 960 960 put_targets_attrs_out: 961 961 kobject_put(&context->targets->kobj); 962 962 context->targets = NULL; 963 - put_attrs_out: 963 + rmdir_put_attrs_out: 964 + damon_sysfs_attrs_rm_dirs(context->attrs); 964 965 kobject_put(&context->attrs->kobj); 965 966 context->attrs = NULL; 966 967 return err;