public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: 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>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] perf stat: Potential NULL dereference in print_aggr()
Date: Sun, 14 Oct 2018 16:04:46 +0200	[thread overview]
Message-ID: <20181014140446.GA24104@krava> (raw)
In-Reply-To: <20181013101940.GA16086@mwanda>

On Sat, Oct 13, 2018 at 01:19:40PM +0300, Dan Carpenter wrote:
> Smatch complains that:
> 
>     ./tools/perf/util/stat-display.c:616 print_aggr()
>     error: we previously assumed 'config->aggr_map' could be null (see line 607)
> 
> Not only that, but it looks like aggr_update_shadow() can Oops if
> "config->aggr_get_id" is NULL.  The intent seems to have been to return
> if either of these pointers is NULL.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Fixes: 86ee6e18f6cb ("perf stat: Refactor aggregation code")

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/util/stat-display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index e7b4c44ebb62..db635c01d3a3 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -604,7 +604,7 @@ static void print_aggr(struct perf_stat_config *config,
>  	u64 ena, run, val;
>  	bool first;
>  
> -	if (!(config->aggr_map || config->aggr_get_id))
> +	if (!config->aggr_map || !config->aggr_get_id)
>  		return;
>  
>  	aggr_update_shadow(config, evlist);
> -- 
> 2.18.0
> 

      reply	other threads:[~2018-10-14 14:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13 10:19 [PATCH] perf stat: Potential NULL dereference in print_aggr() Dan Carpenter
2018-10-14 14:04 ` Jiri Olsa [this message]

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=20181014140446.GA24104@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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