From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH perf-tools-next v2 2/4] perf ftrace: Support filtering return address comments
Date: Tue, 06 Oct 2026 23:37:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-162514@kernel.org> (raw)
In-Reply-To: <20261006232756.65620-3-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf/ftrace: memory leak of trace buffer on error paths in __cmd_ftrace()
--
commit 473e334ba892f3b7d5261168be5e86956a4de438
Author: Aaron Tomlin <atomlin@atomlin.com>
perf ftrace: Support filtering return address comments
This commit introduces a feature to filter out return address comments from
the function graph tracer output in perf ftrace. It implements parsing and
filtering logic, adds a --filter-retaddr command-line option, and includes
unit tests for validation.
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -827,6 +827,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace)
> break;
> for (int i = 0; i < n; i++) {
> if (buf[i] == '\n') {
> + if (ftrace->filter_retaddr)
> + ftrace_filter_retaddr(linebuf.buf);
> fprintf(stdout, "%s\n", linebuf.buf);
> strbuf_setlen(&linebuf, 0);
[Severity: Medium]
Does __cmd_ftrace() in tools/perf/builtin-ftrace.c leak the allocated buf
and linebuf on error paths?
Looking at the initialization sequence, buf is dynamically allocated and
linebuf is initialized:
buf = malloc(TRACE_BUF_SIZE);
if (!buf) {
pr_err("failed to allocate trace buffer\n");
goto out_reset;
}
strbuf_init(&linebuf, 512);
However, if get_tracing_instance_file() fails or trace_fd fails to open,
the code jumps to out_reset:
if (!trace_file) {
pr_err("failed to open trace_pipe\n");
goto out_reset;
}
The out_reset label is located after the cleanup for buf and linebuf:
out_close_fd:
free(buf);
strbuf_release(&linebuf);
close(trace_fd);
out_reset:
exit_tracing_instance();
Will this bypass the free(buf) and strbuf_release(&linebuf) calls, causing
a regression where these resources are leaked when early error paths are
taken?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261006232756.65620-1-atomlin@atomlin.com?part=2
next prev parent reply other threads:[~2026-10-06 23:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 23:27 [PATCH perf-tools-next v2 0/4] perf ftrace: Support inlined functions and display enhancements in function graph tracer Aaron Tomlin
2026-10-06 23:27 ` [PATCH perf-tools-next v2 1/4] perf ftrace: Optimise __cmd_ftrace() stack frame with strbuf streaming Aaron Tomlin
2026-10-06 23:35 ` sashiko-bot
2026-10-07 15:46 ` Aaron Tomlin
2026-10-06 23:27 ` [PATCH perf-tools-next v2 2/4] perf ftrace: Support filtering return address comments Aaron Tomlin
2026-10-06 23:37 ` sashiko-bot [this message]
2026-10-07 16:04 ` Aaron Tomlin
2026-10-06 23:27 ` [PATCH perf-tools-next v2 3/4] perf ftrace: Support display of inlined functions in function graph tracer Aaron Tomlin
2026-10-06 23:40 ` sashiko-bot
2026-10-06 23:27 ` [PATCH perf-tools-next v2 4/4] perf ftrace: Support omitting execution duration " Aaron Tomlin
2026-10-06 23:35 ` sashiko-bot
2026-10-07 23:24 ` [PATCH perf-tools-next v2 0/4] perf ftrace: Support inlined functions and display enhancements " Namhyung Kim
2026-10-10 21:07 ` Aaron Tomlin
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=sashiko-outbox-162514@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atomlin@atomlin.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.