FAILED: patch "[PATCH] perf python: Free the parse error entries when parsing fails" failed to apply to 6.18-stable tree
Subsystems (2)
Sasha Levin
maintainerThe 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
@@ -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
Sasha Levin
maintainerPATCH 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.
--- tools/perf/util/python.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
@@ -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