perf python: Fix memory leak in pyrf_evlist__get_pollfd

Fix a Python list object leak in pyrf_evlist__get_pollfd() by adding
a missing Py_DECREF on the error exit path.

Assisted-by: Antigravity:gemini-3.1-pro
Fixes: 877108e42b ("perf tools: Initial python binding")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Ian Rogers 2026-08-09 00:14:43 -07:00 committed by Namhyung Kim
parent 08e96e3c73
commit 38d778acbe

View File

@ -2825,6 +2825,8 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,
evlist = pevlist->evlist;
list = PyList_New(0);
if (!list)
return NULL;
for (i = 0; i < evlist__core(evlist)->pollfd.nr; ++i) {
PyObject *file;
@ -2843,6 +2845,7 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,
return list;
free_list:
Py_XDECREF(list);
return PyErr_NoMemory();
}