Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf parse-events: free evsel and config terms if term conversion fails
@ 2026-11-13  8:52 Gu Bin
  2026-11-13  9:00 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Gu Bin @ 2026-11-13  8:52 UTC (permalink / raw)
  To: acme
  Cc: peterz, mingo, namhyung, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, james.clark, linux-perf-users,
	linux-kernel

add_tracepoint() creates the evsel with evsel__newtp_idx() before
converting the user-supplied config terms with get_config_terms().
If a term allocation fails there, the function returns -ENOMEM with
the evsel not yet on any list, so nobody frees it, and the terms
that get_config_terms() already queued on the local config_terms
list are leaked as well.

Free the partially built config_terms list, then release the evsel
with evsel__put(), before returning.

Fixes: e637d17757a1 ("perf tools: Enable event_config terms to tracepoint events")
Signed-off-by: Gu Bin <gubin@cmss.chinamobile.com>
---
 tools/perf/util/parse-events.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index f3ba70d4f76b..e4f842532145 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -490,8 +490,11 @@ static int add_tracepoint(struct parse_events_state *parse_state,
 	if (head_config) {
 		LIST_HEAD(config_terms);
 
-		if (get_config_terms(head_config, &config_terms))
+		if (get_config_terms(head_config, &config_terms)) {
+			free_config_terms(&config_terms);
+			evsel__put(evsel);
 			return -ENOMEM;
+		}
 		list_splice(&config_terms, &evsel->config_terms);
 	}
 
-- 
2.50.1.windows.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-13  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  8:52 [PATCH] perf parse-events: free evsel and config terms if term conversion fails Gu Bin
2026-11-13  9:00 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox