From: Dan Carpenter <dan.carpenter@linaro.org>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
damon@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH next] mm/damon/tests/sysfs-kunit: fix use after free on error path
Date: Fri, 21 Nov 2025 16:36:38 +0300 [thread overview]
Message-ID: <aSBq5uSPIqsqH8zO@stanley.mountain> (raw)
Re-order these frees to avoid dereferencing "sysfs_target" after it has
been freed.
Fixes: ee131696794c ("mm/damon/tests/sysfs-kunit: handle alloc failures on damon_sysfs_test_add_targets()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
mm/damon/tests/sysfs-kunit.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/tests/sysfs-kunit.h b/mm/damon/tests/sysfs-kunit.h
index ce7218469f20..0c665ed255a3 100644
--- a/mm/damon/tests/sysfs-kunit.h
+++ b/mm/damon/tests/sysfs-kunit.h
@@ -76,8 +76,8 @@ static void damon_sysfs_test_add_targets(struct kunit *test)
if (!ctx) {
kfree(sysfs_targets->targets_arr);
kfree(sysfs_targets);
- kfree(sysfs_target);
kfree(sysfs_target->regions);
+ kfree(sysfs_target);
kunit_skip(test, "ctx alloc fail");
}
--
2.51.0
next reply other threads:[~2025-11-21 13:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 13:36 Dan Carpenter [this message]
2025-11-21 16:35 ` 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=aSBq5uSPIqsqH8zO@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox