From: SJ Park <sj@kernel.org>
Cc: SJ Park <sj@kernel.org>,
stable@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: [RFC PATCH 6.12.y 1/2] mm/damon/sysfs: put target pids for damon_start() failure
Date: Tue, 27 Oct 2026 21:26:14 -0700 [thread overview]
Message-ID: <20261028042617.165657-2-sj@kernel.org> (raw)
In-Reply-To: <20261028042617.165657-1-sj@kernel.org>
damon_sysfs_turn_damon_on() allocates and sets up damon_ctx to start.
If it is for virtual address space monitoring, the setup increases the
reference counts of the target pids. After the setup, the function
invokes damon_start(). If damon_start() fails, it deallocates the
damon_ctx object without decreasing the reference counts of target pids.
As a result, pids can be leaked.
Fix the leak by putting pids using damon_sysfs_destroy_targets() before
deallocating the damon_ctx object.
Fixes: a61ea561c871 ("mm/damon/sysfs: link DAMON for virtual address spaces monitoring")
Cc: <stable@vger.kernel.org> # 5.18.x
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 5aa23c6545cb8..107a28557afe2 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1519,6 +1519,7 @@ static int damon_sysfs_turn_damon_on(struct damon_sysfs_kdamond *kdamond)
return PTR_ERR(ctx);
err = damon_start(&ctx, 1, false);
if (err) {
+ damon_sysfs_destroy_targets(ctx);
damon_destroy_ctx(ctx);
return err;
}
--
2.47.3
next prev parent reply other threads:[~2026-10-28 4:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 4:26 [RFC PATCH 6.12.y 0/2] mm/damon/sysfs: fix pid leaks from wrong error handlings SJ Park
2026-10-28 4:26 ` SJ Park [this message]
2026-10-28 4:35 ` [RFC PATCH 6.12.y 1/2] mm/damon/sysfs: put target pids for damon_start() failure sashiko-bot
2026-10-28 4:26 ` [RFC PATCH 6.12.y 2/2] mm/damon/sysfs: put target pids for apply_inputs() failure SJ Park
2026-10-28 4:31 ` sashiko-bot
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=20261028042617.165657-2-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=stable@vger.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.