From: Jiri Olsa <jolsa@redhat.com>
To: Petr Machata <petrm@mellanox.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH] perf: python: Reference Py_None before returning it
Date: Thu, 22 Mar 2018 10:14:48 +0100 [thread overview]
Message-ID: <20180322091448.GA2972@krava> (raw)
In-Reply-To: <b1e565ecccf68064d8d54f37db5d028dda8fa522.1521675563.git.petrm@mellanox.com>
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@mellanox.com>
Acked-by: Jiri Olsa <jolsa@kernel.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
>
next prev parent reply other threads:[~2018-03-22 9:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 23:57 [PATCH] perf: python: Reference Py_None before returning it Petr Machata
2018-03-22 9:14 ` Jiri Olsa [this message]
2018-03-22 9:35 ` Arnaldo Carvalho de Melo
2018-03-25 22:25 ` [tip:perf/core] perf " tip-bot for Petr Machata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180322091448.GA2972@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=petrm@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.