LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] perf/core: Fix reversed NULL check in perf_event_groups_less()
@ 2020-03-12 10:56 Dan Carpenter
  2020-03-13 12:27 ` Peter Zijlstra
  2020-03-20 12:58 ` [tip: perf/core] " tip-bot2 for Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-03-12 10:56 UTC (permalink / raw)
  To: Peter Zijlstra, Ian Rogers
  Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel,
	kernel-janitors

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.
-- 
2.20.1


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

* Re: [PATCH] perf/core: Fix reversed NULL check in perf_event_groups_less()
  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
  2020-03-21  2:24   ` Ian Rogers
  2020-03-20 12:58 ` [tip: perf/core] " tip-bot2 for Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2020-03-13 12:27 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ian Rogers, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel,
	kernel-janitors

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!

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

* [tip: perf/core] perf/core: Fix reversed NULL check in perf_event_groups_less()
  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
@ 2020-03-20 12:58 ` tip-bot2 for Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Dan Carpenter @ 2020-03-20 12:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Dan Carpenter, Peter Zijlstra (Intel), x86, LKML

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     a6763625ae6f8aa5ee82fcd8fa4e5e38db20dbc6
Gitweb:        https://git.kernel.org/tip/a6763625ae6f8aa5ee82fcd8fa4e5e38db20dbc6
Author:        Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate:    Thu, 12 Mar 2020 13:56:37 +03:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 20 Mar 2020 13:06:22 +01:00

perf/core: Fix reversed NULL check in perf_event_groups_less()

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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200312105637.GA8960@mwanda
---
 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 b5a68d2..d22e4ba 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1586,7 +1586,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.

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

* Re: [PATCH] perf/core: Fix reversed NULL check in perf_event_groups_less()
  2020-03-13 12:27 ` Peter Zijlstra
@ 2020-03-21  2:24   ` Ian Rogers
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2020-03-21  2:24 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Dan Carpenter, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim, LKML,
	kernel-janitors

On Fri, Mar 13, 2020 at 5:27 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> 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!

Also much thanks!

Ian

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

end of thread, other threads:[~2020-03-21  2:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-03-21  2:24   ` Ian Rogers
2020-03-20 12:58 ` [tip: perf/core] " tip-bot2 for Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).