From: SeongJae Park <sj@kernel.org>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: SeongJae Park <sj@kernel.org>,
akpm@linux-foundation.org, damon@lists.linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/damon: Fix memory leak in damon_sysfs_test_add_targets()
Date: Thu, 10 Oct 2024 09:21:45 -0700 [thread overview]
Message-ID: <20241010162145.195696-1-sj@kernel.org> (raw)
In-Reply-To: <20241010125323.3127187-1-ruanjinjie@huawei.com>
Hi Jinjie,
On Thu, 10 Oct 2024 20:53:23 +0800 Jinjie Ruan <ruanjinjie@huawei.com> wrote:
> The sysfs_target->regions allocated in damon_sysfs_regions_alloc()
> is not freed in damon_sysfs_test_add_targets(), which cause the following
> memory leak, free it to fix it.
>
> unreferenced object 0xffffff80c2a8db80 (size 96):
> comm "kunit_try_catch", pid 187, jiffies 4294894363
> hex dump (first 32 bytes):
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace (crc 0):
> [<0000000001e3714d>] kmemleak_alloc+0x34/0x40
> [<000000008e6835c1>] __kmalloc_cache_noprof+0x26c/0x2f4
> [<000000001286d9f8>] damon_sysfs_test_add_targets+0x1cc/0x738
> [<0000000032ef8f77>] kunit_try_run_case+0x13c/0x3ac
> [<00000000f3edea23>] kunit_generic_run_threadfn_adapter+0x80/0xec
> [<00000000adf936cf>] kthread+0x2e8/0x374
> [<0000000041bb1628>] ret_from_fork+0x10/0x20
Thank you for catching this issue and posting this fix!
>
> Cc: stable@vger.kernel.org
> Fixes: b8ee5575f763 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets()")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> mm/damon/tests/sysfs-kunit.h | 1 +
> 1 file changed, 1 insertion(+)
Can we update the subject prefix to "mm/damon/tests/sysfs-kunit:"? I think
that will help readers understanding the change more easily.
Other than that,
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
>
> diff --git a/mm/damon/tests/sysfs-kunit.h b/mm/damon/tests/sysfs-kunit.h
> index 1c9b596057a7..7b5c7b307da9 100644
> --- a/mm/damon/tests/sysfs-kunit.h
> +++ b/mm/damon/tests/sysfs-kunit.h
> @@ -67,6 +67,7 @@ static void damon_sysfs_test_add_targets(struct kunit *test)
> damon_destroy_ctx(ctx);
> kfree(sysfs_targets->targets_arr);
> kfree(sysfs_targets);
> + kfree(sysfs_target->regions);
> kfree(sysfs_target);
> }
>
> --
> 2.34.1
prev parent reply other threads:[~2024-10-10 16:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 12:53 Jinjie Ruan
2024-10-10 16:21 ` SeongJae Park [this message]
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=20241010162145.195696-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ruanjinjie@huawei.com \
/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