* [PATCH] perf trace: propagate evsel__set_filter() error in trace__expand_filter()
@ 2026-11-12 8:09 Gu Bin
2026-11-12 8:15 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Gu Bin @ 2026-11-12 8:09 UTC (permalink / raw)
To: acme, namhyung
Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, irogers,
adrian.hunter, linux-perf-users, linux-kernel
At the end of trace__expand_filter(), the return value of
evsel__set_filter() is ignored. When the strdup() inside fails with
-ENOMEM, the function returns 0 anyway, leaving evsel->filter holding
the unexpanded filter, which still contains the symbolic constants the
loop meant to resolve. The failure then surfaces later and indirectly:
evlist__apply_filters() passes the unexpanded string to the tracepoint
filter parser, which rejects the symbolic name, so perf trace fails to
start with a filter syntax error whose real cause is the missed
allocation.
Propagate the error so the -ENOMEM is reported at the source and the
caller fails immediately.
Fixes: 90df0249c2ea ("perf trace: Expand strings in filters to integers")
Signed-off-by: Gu Bin <gubin@cmss.chinamobile.com>
---
tools/perf/builtin-trace.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Found by the sashiko review of the fix to the asprintf() failure path
in the same function ([PATCH] perf trace: guard free(new_filter) to
avoid double-free on OOM), which flagged the unchecked return value of
evsel__set_filter() as a related pre-existing issue:
https://sashiko.dev/#/bug/linux-cbf4bb01-a981-47dc-b440-68e5c9c3e81c
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4094141461f91..ce1a7352ea9dd 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4704,9 +4704,13 @@ static int trace__expand_filter(struct trace *trace, struct evsel *evsel)
}
if (new_filter != evsel->filter) {
+ int err;
+
pr_debug("New filter for %s: %s\n", evsel->name, new_filter);
- evsel__set_filter(evsel, new_filter);
+ err = evsel__set_filter(evsel, new_filter);
free(new_filter);
+ if (err)
+ return err;
}
return 0;
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-12 8:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 8:09 [PATCH] perf trace: propagate evsel__set_filter() error in trace__expand_filter() Gu Bin
2026-11-12 8:15 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox