From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 6.1.y] mm/damon/sysfs-schemes: kobject_del() scheme dirs
Date: Wed, 09 Sep 2026 04:05:49 +0000 [thread overview]
Message-ID: <20260909040549.D50701F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909035529.159422-1-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix: Missing `kobject_del()` for dynamically sized sysfs array directories (kdamonds, contexts, targets, regions) causes name conflicts on recreation.
--
commit 313d3e99fc72ef8df36e0924dc61e045a278961d
Author: SJ Park <sj@kernel.org>
mm/damon/sysfs-schemes: kobject_del() scheme dirs
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for scheme directories by adding kobject_del() calls.
Link: https://lore.kernel.org/20260628220121.97360-4-sj@kernel.org
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index bb2f4650741fa..7e4fb112d1154 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -954,6 +954,7 @@ static void damon_sysfs_schemes_rm_dirs(struct damon_sysfs_schemes *schemes)
>
> for (i = 0; i < schemes->nr; i++) {
> damon_sysfs_scheme_rm_dirs(schemes_arr[i]);
> + kobject_del(&schemes_arr[i]->kobj);
> kobject_put(&schemes_arr[i]->kobj);
> }
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this fix for
the schemes directories, it appears the exact same omission of kobject_del()
is still present for other dynamically sized sysfs arrays (kdamonds,
contexts, targets, and regions).
For instance, in damon_sysfs_kdamonds_rm_dirs():
static void damon_sysfs_kdamonds_rm_dirs(struct damon_sysfs_kdamonds *kdamonds)
{
...
for (i = 0; i < kdamonds->nr; i++) {
damon_sysfs_kdamond_rm_dirs(kdamonds_arr[i]);
kobject_put(&kdamonds_arr[i]->kobj);
}
...
}
When updating these directories, the old directories are dropped using only
kobject_put() and new ones are immediately added with kobject_init_and_add()
using the same names. If CONFIG_DEBUG_KOBJECT_RELEASE is enabled or a
reference is held, won't this deferred removal leave the old directory
active and cause the recreation to fail with -EEXIST?
Should kobject_del() also be added to damon_sysfs_kdamonds_rm_dirs(),
damon_sysfs_contexts_rm_dirs(), damon_sysfs_targets_rm_dirs(), and
damon_sysfs_regions_rm_dirs() to prevent these same name conflicts?
> @@ -991,13 +992,15 @@ static int damon_sysfs_schemes_add_dirs(struct damon_sysfs_schemes *schemes,
> goto out;
> err = damon_sysfs_scheme_add_dirs(scheme);
> if (err)
> - goto out;
> + goto del_out;
>
> schemes_arr[i] = scheme;
> schemes->nr++;
> }
> return 0;
>
> +del_out:
> + kobject_del(&scheme->kobj);
> out:
> damon_sysfs_schemes_rm_dirs(schemes);
> kobject_put(&scheme->kobj);
[Severity: High]
This is also a pre-existing issue, but similar to the rm_dirs() paths, the
error paths for adding other array elements appear to be missing
kobject_del().
For example, in damon_sysfs_kdamonds_add_dirs():
for (i = 0; i < nr_kdamonds; i++) {
...
err = kobject_init_and_add(&kdamond->kobj,
&damon_sysfs_kdamond_ktype, &kdamonds->kobj,
"%d", i);
if (err)
goto out;
err = damon_sysfs_kdamond_add_dirs(kdamond);
if (err)
goto out;
...
out:
damon_sysfs_kdamonds_rm_dirs(kdamonds);
kobject_put(&kdamond->kobj);
return err;
If adding the child directories via damon_sysfs_kdamond_add_dirs() fails,
the parent kdamond->kobj has already been added to sysfs. Doesn't branching
directly to 'out' leave a lingering sysfs node without calling kobject_del()?
Should a similar 'del_out' error path be added to
damon_sysfs_kdamonds_add_dirs(), damon_sysfs_contexts_add_dirs(), and
damon_sysfs_targets_add_dirs()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909035529.159422-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-09-09 4:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026090817-livable-sturdily-4c48@gregkh>
2026-09-09 3:55 ` [PATCH 6.1.y] mm/damon/sysfs-schemes: kobject_del() scheme dirs SJ Park
2026-09-09 4:05 ` sashiko-bot [this message]
2026-09-09 20:26 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260909040549.D50701F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.