[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180322091448.GA2972@krava>
Date: Thu, 22 Mar 2018 10:14:48 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: Petr Machata <petrm@...lanox.com>
Cc: linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>
Subject: Re: [PATCH] perf: python: Reference Py_None before returning it
On Thu, Mar 22, 2018 at 12:57:32AM +0100, Petr Machata wrote:
> 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@...lanox.com>
Acked-by: Jiri Olsa <jolsa@...nel.org>
thanks,
jirka
> ---
> 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
>
Powered by blists - more mailing lists