All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: python: Reference Py_None before returning it
@ 2018-03-21 23:57 Petr Machata
  2018-03-22  9:14 ` Jiri Olsa
  2018-03-25 22:25 ` [tip:perf/core] perf " tip-bot for Petr Machata
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Machata @ 2018-03-21 23:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Petr Machata

Python None objects are handled just like all the other objects with
respect to their reference counting. Before returning Py_None, its
reference count thus needs to be bumped.

Signed-off-by: Petr Machata <petrm@mellanox.com>
---
 tools/perf/util/python.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index b1e999b..762d429 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -967,8 +967,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 			return PyErr_NoMemory();
 
 		evsel = perf_evlist__event2evsel(evlist, event);
-		if (!evsel)
+		if (!evsel) {
+			Py_INCREF(Py_None);
 			return Py_None;
+		}
 
 		pevent->evsel = evsel;
 
-- 
2.4.3

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

end of thread, other threads:[~2018-03-25 22:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-21 23:57 [PATCH] perf: python: Reference Py_None before returning it Petr Machata
2018-03-22  9:14 ` Jiri Olsa
2018-03-22  9:35   ` Arnaldo Carvalho de Melo
2018-03-25 22:25 ` [tip:perf/core] perf " tip-bot for Petr Machata

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.