Skip to contentSkip to conversation

FAILED: patch "[PATCH] perf python: Free the parse error entries when parsing fails" failed to apply to 6.18-stable tree

PATCH New Sasha Levin 1 participant 2 messages Nov 7 – Nov 10

Subsystems (2)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 39e0022c89abcdc1a811dfc0aeec2a2b9010b660
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From 39e0022c89abcdc1a811dfc0aeec2a2b9010b660 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, 15 Oct 2026 22:06:19 -0300
Subject: [PATCH] perf python: Free the parse error entries when parsing fails

pyrf__parse_events() prints the entries parse_events_error__print() receives with the details of a failed parse, but returns without freeing them, leaking whatever parse_events_error__handle() allocated, so call parse_events_error__exit() on both paths, as the other parse_events() callers do.

The perf test attr core PMU probe takes this failure path on machines without a core PMU, where the leak then happens on every test run.

---
 tools/perf/util/python.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
index 4eb17bdc5fd12..60dbe2dad5eb8 100644
@@ -3824,10 +3824,12 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
 	perf_evlist__set_maps(evlist__core(evlist), cpus, threads);
 	if (parse_events(evlist, input, &err)) {
 		parse_events_error__print(&err, input);
+		parse_events_error__exit(&err);
 		PyErr_SetFromErrno(PyExc_OSError);
 		evlist__put(evlist);
 		return NULL;
 	}
+	parse_events_error__exit(&err);
 	result = pyrf_evlist__from_evlist(evlist);
 	evlist__put(evlist);
 	return result;
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/1 perf python: Free the parse error entries when parsing fails

From: Arnaldo Carvalho de Melo <[email protected]>

[ Upstream commit 39e0022c89abcdc1a811dfc0aeec2a2b9010b660 ]

pyrf__parse_events() prints the entries parse_events_error__print() receives with the details of a failed parse, but returns without freeing them, leaking whatever parse_events_error__handle() allocated, so call parse_events_error__exit() on both paths, as the other parse_events() callers do.

The perf test attr core PMU probe takes this failure path on machines without a core PMU, where the leak then happens on every test run.

Fixes f081defccd93 ("perf python: Add parse_events function")
Assisted-by LLM
[ sashal: adjusted context for a stack-allocated event list using evlist__exit() instead of evlist__put() ]
---
 tools/perf/util/python.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
index a65a4d9f8cc83..2fa9670bc51f0 100644
@@ -2075,9 +2075,11 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
 	evlist__init(&evlist, cpus, threads);
 	if (parse_events(&evlist, input, &err)) {
 		parse_events_error__print(&err, input);
+		parse_events_error__exit(&err);
 		PyErr_SetFromErrno(PyExc_OSError);
 		return NULL;
 	}
+	parse_events_error__exit(&err);
 	result = pyrf_evlist__from_evlist(&evlist);
 	evlist__exit(&evlist);
 	return result;
Signature · 1 line
2.53.0