kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf stat: Potential NULL dereference in print_aggr()
@ 2018-10-13 10:19 Dan Carpenter
  2018-10-14 14:04 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-10-13 10:19 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, linux-kernel, kernel-janitors

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

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

end of thread, other threads:[~2018-10-14 14:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-13 10:19 [PATCH] perf stat: Potential NULL dereference in print_aggr() Dan Carpenter
2018-10-14 14:04 ` Jiri Olsa

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