[RFC PATCH v1.1 11/11] mm/damon/sysfs-schemes: kobject_del() region for populate_region error

From: SeongJae Park

Date: Wed Jun 17 2026 - 10:49:53 EST


On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts.
Fix the issue for tried region directories in the error handling path of
damon_sysfs_populate_region_dir() by adding a kobject_del() call.

Fixes: b574a82d10de ("mm/damon/sysfs-schemes: implement tried_regions/<r>/probes/")
Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/damon/sysfs-schemes.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 0c0c9637b594e..d3b414f7bd205 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -3132,12 +3132,14 @@ void damos_sysfs_populate_region_dir(struct damon_sysfs_schemes *sysfs_schemes,
sysfs_regions->nr_regions))
goto out;
if (damos_sysfs_region_add_dirs(region, ctx, r))
- goto out;
+ goto del_out;

list_add_tail(&region->list, &sysfs_regions->regions_list);
sysfs_regions->nr_regions++;
return;

+del_out:
+ kobject_del(&region->kobj);
out:
kobject_put(&region->kobj);
}
--
2.47.3