mm/damon/sysfs: cleanup attrs subdirs on context dir setup failure
commit9814cc832bupstream. 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:c951cd3b89("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9dc11b365e
commit
78b4eb9975
@@ -922,7 +922,7 @@ static int damon_sysfs_context_add_dirs(struct damon_sysfs_context *context)
|
||||
|
||||
err = damon_sysfs_context_set_targets(context);
|
||||
if (err)
|
||||
goto put_attrs_out;
|
||||
goto rmdir_put_attrs_out;
|
||||
|
||||
err = damon_sysfs_context_set_schemes(context);
|
||||
if (err)
|
||||
@@ -932,7 +932,8 @@ static int damon_sysfs_context_add_dirs(struct damon_sysfs_context *context)
|
||||
put_targets_attrs_out:
|
||||
kobject_put(&context->targets->kobj);
|
||||
context->targets = NULL;
|
||||
put_attrs_out:
|
||||
rmdir_put_attrs_out:
|
||||
damon_sysfs_attrs_rm_dirs(context->attrs);
|
||||
kobject_put(&context->attrs->kobj);
|
||||
context->attrs = NULL;
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user