From: sashiko-bot@kernel.org
To: "Suhaas Joshi" <suhaas@s-joshi.in>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions()
Date: Wed, 07 Oct 2026 15:58:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-163177@kernel.org> (raw)
In-Reply-To: <20261007154851.45368-2-suhaas@s-joshi.in>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm: memory leak of ctx on r2 allocation failure in damon_test_merge_two()
--
commit ade902b9c0636f895031124ead4ff579818b8169
Author: Suhaas Joshi <suhaas@s-joshi.in>
mm/damon/core: Use only installed probe in damon_merge_two_regions()
While merging 2 regions, we iterate over the entire probe_hits[] array,
whose size is determined by the DAMON_MAX_PROBES macro. It is possible,
however, that we have fewer probes installed than DAMON_MAX_PROBES. In such
cases, we end up making redundant iterations. Therefore, to remedy this,
iterate over the list of installed probes instead of iterating over the
entire array. For doing this, start accepting a struct damon_ctx in
damon_merge_two_regions(), and update calling functions to pass this
argument.
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index ef146ca2ae8aa..bea17b68f13c6 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -182,13 +182,27 @@ static void damon_test_merge_two(struct kunit *test)
> {
> struct damon_target *t;
> struct damon_region *r, *r2, *r3;
> + struct damon_probe *p;
> + struct damon_ctx *ctx;
> int i;
>
> + p = damon_new_probe();
> + if (!p)
> + kunit_skip(test, "probe alloc fail");
> + ctx = damon_new_ctx();
> + if (!ctx) {
> + damon_destroy_probe(p);
> + kunit_skip(test, "context alloc fail");
> + }
> + damon_add_probe(ctx, p);
> t = damon_new_target();
> - if (!t)
> + if (!t) {
> + damon_destroy_ctx(ctx);
> kunit_skip(test, "target alloc fail");
> + }
> r = damon_new_region(0, 100);
> if (!r) {
> + damon_destroy_ctx(ctx);
> damon_free_target(t);
> kunit_skip(test, "region alloc fail");
> }
[Severity: Medium]
Is there a missing call to damon_destroy_ctx(ctx) if the allocation for
the second region (r2) fails?
Looking at damon_test_merge_two(), if r2 fails to allocate:
r2 = damon_new_region(100, 300);
if (!r2) {
damon_free_target(t);
kunit_skip(test, "second region alloc fail");
}
Does this code leak the newly allocated ctx and its contained probe on this
error path?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261007154851.45368-2-suhaas@s-joshi.in?part=1
next prev parent reply other threads:[~2026-10-07 15:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261007154851.45368-1-suhaas@s-joshi.in>
2026-10-07 15:48 ` [PATCH 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions() Suhaas Joshi
2026-10-07 15:58 ` sashiko-bot [this message]
2026-10-08 10:40 ` Liew Rui Yan
2026-10-08 10:44 ` SJ Park
2026-10-07 15:48 ` [PATCH 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at() Suhaas Joshi
2026-10-07 16:00 ` sashiko-bot
2026-10-08 10:44 ` Liew Rui Yan
2026-10-08 11:03 ` 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=sashiko-outbox-163177@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=suhaas@s-joshi.in \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox