From: Vincent Donnefort <vdonnefort@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
linux-trace-kernel@vger.kernel.org, kernel-team@android.com,
linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v1] tracing/remotes: Fix leak in trace_remote_alloc_buffer() error path
Date: Thu, 9 Jul 2026 13:18:37 +0100 [thread overview]
Message-ID: <ak-Rnf6qhbYFxTgC@google.com> (raw)
In-Reply-To: <20260708125906.746f1def@gandalf.local.home>
On Wed, Jul 08, 2026 at 12:59:06PM -0400, Steven Rostedt wrote:
> On Wed, 8 Jul 2026 14:32:01 +0100
> Vincent Donnefort <vdonnefort@google.com> wrote:
>
> > If page allocation fails in trace_remote_alloc_buffer(), desc->nr_cpus
> > is not yet incremented for the current CPU. As a consequence, on error,
> > half-allocated rb_desc will not be freed in trace_remote_free_buffer().
> >
> > Include the failing CPU in desc->nr_cpus before going to the error path.
> >
>
> Looks like Sashiko found other issues you may want to address:
>
> https://sashiko.dev/#/patchset/20260708133201.295072-1-vdonnefort%40google.com
Yeah I saw it, the dreaded "This isn't a bug introduced by this patch" ...
Let me send a follow-up. After looking at the other issue, I think I want to
slightly modify this one actually!
>
> -- Steve
>
> > Fixes: 96e43537af54 ("tracing: Introduce trace remotes")
> > Reported-by: Sashiko <sashiko-bot@kernel.org>
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> >
> > diff --git a/kernel/trace/trace_remote.c b/kernel/trace/trace_remote.c
> > index 2a6cc000ec98..62d3d431c309 100644
> > --- a/kernel/trace/trace_remote.c
> > +++ b/kernel/trace/trace_remote.c
> > @@ -1008,8 +1008,10 @@ int trace_remote_alloc_buffer(struct trace_buffer_desc *desc, size_t desc_size,
> >
> > for (id = 0; id < nr_pages; id++) {
> > rb_desc->page_va[id] = (unsigned long)__get_free_page(GFP_KERNEL);
> > - if (!rb_desc->page_va[id])
> > + if (!rb_desc->page_va[id]) {
> > + desc->nr_cpus++; /* Free this partially-allocated rb_desc */
> > goto err;
> > + }
> >
> > rb_desc->nr_page_va++;
> > }
> >
> > base-commit: 8cdeaa50eae8dad34885515f62559ee83e7e8dda
>
prev parent reply other threads:[~2026-07-09 12:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 13:32 [PATCH v1] tracing/remotes: Fix leak in trace_remote_alloc_buffer() error path Vincent Donnefort
2026-07-08 16:59 ` Steven Rostedt
2026-07-09 12:18 ` Vincent Donnefort [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=ak-Rnf6qhbYFxTgC@google.com \
--to=vdonnefort@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sashiko-bot@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