From: sashiko-bot@kernel.org
To: "SeongJae Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.1 04/14] mm/damon/tests/vaddr-kunit: replace damon_add_region() with damon_set_regions()
Date: Thu, 21 May 2026 04:05:25 +0000 [thread overview]
Message-ID: <20260521040526.620A81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521035349.87565-5-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Memory leak of the `damon_target` structure and attached regions when `damon_set_regions()` fails.
--
commit e0458a31c6f6c7f46d6a9ef3e90d4098d89686fd
Author: SeongJae Park <sj@kernel.org>
mm/damon/tests/vaddr-kunit: replace damon_add_region() with damon_set_regions()
This commit updates the DAMON virtual address operation set unit tests to
use damon_set_regions() instead of damon_add_region() for region setup. This
aligns the tests with how other DAMON API callers set up regions.
> diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
> index 98e734d77d517..de30db9b753e5 100644
> --- a/mm/damon/tests/vaddr-kunit.h
> +++ b/mm/damon/tests/vaddr-kunit.h
> @@ -132,22 +132,32 @@ static void damon_do_test_apply_three_regions(struct kunit *test,
> unsigned long *expected, int nr_expected)
> {
> struct damon_target *t;
[ ... ]
> t = damon_new_target();
> if (!t)
> kunit_skip(test, "target alloc fail");
> +
> + ranges = kmalloc_array(nr_regions / 2, sizeof(*ranges), GFP_KERNEL);
> + if (!ranges) {
> + damon_destroy_target(t, NULL);
> + kunit_skip(test, "ranges alloc fail");
> + }
[ ... ]
> + if (damon_set_regions(t, ranges, nr_regions / 2,
> + DAMON_MIN_REGION_SZ)) {
> + kfree(ranges);
> + kunit_skip(test, "damon_set_regions() fail");
[Severity: Medium]
Does this error path leak the damon_target structure and its attached regions?
Unlike the earlier kmalloc_array() error path which calls
damon_destroy_target(t, NULL) before skipping, this failure path seems
to omit the cleanup. Because kunit_skip() aborts test execution via a
long jump, the target allocated via damon_new_target() wouldn't get freed.
> }
> + kfree(ranges);
>
> - damon_set_regions(t, three_regions, 3, DAMON_MIN_REGION_SZ);
> + if (damon_set_regions(t, three_regions, 3, DAMON_MIN_REGION_SZ))
> + kunit_skip(test, "second damon_set_regions() fail");
[Severity: Medium]
Could the same memory leak occur here?
If the second damon_set_regions() fails, kunit_skip() is called without
first freeing the target structure.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260521035349.87565-1-sj@kernel.org?part=4
next prev parent reply other threads:[~2026-05-21 4:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 3:53 [RFC PATCH v1.1 00/14] mm/damon: minor improvements for code readability and tests SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 01/14] mm/damon/core: safely handle no region case in damon_set_regions() SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 02/14] mm/damon/core: do not use region out of a loop " SeongJae Park
2026-05-21 4:19 ` sashiko-bot
2026-05-21 6:05 ` SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 03/14] samples/damon/mtier: replace damon_add_region() with damon_set_regions() SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 04/14] mm/damon/tests/vaddr-kunit: " SeongJae Park
2026-05-21 4:05 ` sashiko-bot [this message]
2026-05-21 5:24 ` SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 05/14] mm/damon/core: hide damon_add_region() SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 06/14] mm/damon/core: hide damon_insert_region() SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 07/14] mm/damon/core: hide damon_destroy_region() SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 08/14] mm/damon/core: add kdamond_call() debug_sanity check SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 09/14] mm/damon/core: remove damon_verify_nr_regions() SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 10/14] mm/damon/tests/core-kunit: add damon_set_regions() test cases SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 11/14] selftests/damon/sysfs.py: stop kdamonds before failing SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 12/14] selftests/damon/sysfs.sh: test monitoring intervals goal dir SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 13/14] selftests/damon/sysfs.sh: test addr_unit file existence SeongJae Park
2026-05-21 3:53 ` [RFC PATCH v1.1 14/14] selftests/damon/sysfs.sh: test pause " SeongJae 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=20260521040526.620A81F000E9@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.