From: Peter Zijlstra <peterz@infradead.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ian Rogers <irogers@google.com>, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] perf/core: Fix reversed NULL check in perf_event_groups_less()
Date: Fri, 13 Mar 2020 13:27:25 +0100 [thread overview]
Message-ID: <20200313122725.GZ12561@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200312105637.GA8960@mwanda>
On Thu, Mar 12, 2020 at 01:56:37PM +0300, Dan Carpenter wrote:
> This NULL check is reversed so it leads to a Smatch warning and
> presumably a NULL dereference.
>
> kernel/events/core.c:1598 perf_event_groups_less()
> error: we previously assumed 'right->cgrp->css.cgroup' could be null
> (see line 1590)
>
> Fixes: 95ed6c707f26 ("perf/cgroup: Order events in RB tree by cgroup id")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> kernel/events/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 6a47c3e54fe9..607c04ec7cfa 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -1587,7 +1587,7 @@ perf_event_groups_less(struct perf_event *left, struct perf_event *right)
> */
> return true;
> }
> - if (!right->cgrp || right->cgrp->css.cgroup) {
> + if (!right->cgrp || !right->cgrp->css.cgroup) {
> /*
> * Right has no cgroup but left does, no cgroups come
> * first.
Thanks!
next prev parent reply other threads:[~2020-03-13 12:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 10:56 [PATCH] perf/core: Fix reversed NULL check in perf_event_groups_less() Dan Carpenter
2020-03-13 12:27 ` Peter Zijlstra [this message]
2020-03-21 2:24 ` Ian Rogers
2020-03-20 12:58 ` [tip: perf/core] " tip-bot2 for Dan Carpenter
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=20200313122725.GZ12561@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=dan.carpenter@oracle.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox