Skip to content

Commit

Permalink
perf python: Reference Py_None before returning it
Browse files Browse the repository at this point in the history
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>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Machata <petrm@mellanox.com>
Link: http://lkml.kernel.org/r/b1e565ecccf68064d8d54f37db5d028dda8fa522.1521675563.git.petrm@mellanox.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Petr Machata authored and Arnaldo Carvalho de Melo committed Mar 23, 2018
1 parent 751b178 commit 83428f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,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;

Expand Down

0 comments on commit 83428f2

Please sign in to comment.