From: sashiko-bot@kernel.org
To: "Guangshuo Li" <lgs201920130244@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH] mm/damon/sysfs-schemes: fix tried_regions setup failure cleanup
Date: Wed, 08 Jul 2026 08:20:09 +0000 [thread overview]
Message-ID: <20260708082010.10E441F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708080107.727043-1-lgs201920130244@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Uninitialized pointer dereference in error path of damon_sysfs_access_pattern_add_dirs()
--
--- Patch [1]: [PATCH] mm/damon/sysfs-schemes: fix tried_regions setup failure cleanup ---
commit b97caf8d3b939c01dca3a53c5340d70ede6714d2
Author: Guangshuo Li <lgs201920130244@gmail.com>
mm/damon/sysfs-schemes: fix tried_regions setup failure cleanup
This commit fixes an uninitialized pointer dereference in the error cleanup
path of damon_sysfs_scheme_add_dirs(). It changes the failure jump target
for damon_sysfs_scheme_set_tried_regions() to avoid calling kobject_put()
on the uninitialized tried_regions pointer.
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 329cfd0bbe9f3..0668a0e539713 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
> @@ -2516,12 +2516,12 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme)
> goto put_filters_watermarks_quotas_access_pattern_out;
> err = damon_sysfs_scheme_set_tried_regions(scheme);
> if (err)
> - goto put_tried_regions_out;
> + goto put_stats_out;
> return 0;
>
> -put_tried_regions_out:
> - kobject_put(&scheme->tried_regions->kobj);
> - scheme->tried_regions = NULL;
> +put_stats_out:
> + kobject_put(&scheme->stats->kobj);
> + scheme->stats = NULL;
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this cleanup,
I noticed the exact same uninitialized pointer dereference exists earlier in
the same file.
If damon_sysfs_access_pattern_add_range_dir() fails during the setup of "sz",
does the error path dereference an uninitialized pointer?
mm/damon/sysfs-schemes.c: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;
...
put_sz_out:
kobject_put(&access_pattern->sz->kobj);
access_pattern->sz = NULL;
return err;
}
Since damon_sysfs_access_pattern is allocated with kmalloc_obj(), its fields
are uninitialized. If the directory creation fails, the function returns an
error without writing to the pointer. The error path then jumps to put_sz_out
and calls kobject_put() on the garbage pointer access_pattern->sz, identical
to the bug fixed by this patch.
Could this be addressed with a similar fix?
> put_filters_watermarks_quotas_access_pattern_out:
> kobject_put(&scheme->ops_filters->kobj);
> scheme->ops_filters = NULL;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708080107.727043-1-lgs201920130244@gmail.com?part=1
next prev parent reply other threads:[~2026-07-08 8:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 8:01 [PATCH] mm/damon/sysfs-schemes: fix tried_regions setup failure cleanup Guangshuo Li
2026-07-08 8:20 ` sashiko-bot [this message]
2026-07-08 14:22 ` SJ Park
2026-07-08 14:17 ` SJ Park
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=20260708082010.10E441F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=lgs201920130244@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.