Skip to content

Commit

Permalink
perf stat: Fix NULL pointer dereference
Browse files Browse the repository at this point in the history
If config->aggr_map is NULL and config->aggr_get_id is not NULL,
the function print_aggr() will still calling arrg_update_shadow(),
which can result in accessing the invalid pointer.

Fixes: 088519f ("perf stat: Move the display functions to stat-display.c")
Signed-off-by: Hongbo Yao <yaohongbo@huawei.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wei Li <liwei391@huawei.com>
Link: https://lore.kernel.org/lkml/20200608163625.GC3073@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Hongbo Yao authored and Arnaldo Carvalho de Melo committed Jun 9, 2020
1 parent 11b6e54 commit c0c652f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/perf/util/stat-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ static void print_aggr(struct perf_stat_config *config,
int s;
bool first;

if (!(config->aggr_map || config->aggr_get_id))
if (!config->aggr_map || !config->aggr_get_id)
return;

aggr_update_shadow(config, evlist);
Expand Down Expand Up @@ -1169,7 +1169,7 @@ static void print_percore(struct perf_stat_config *config,
int s;
bool first = true;

if (!(config->aggr_map || config->aggr_get_id))
if (!config->aggr_map || !config->aggr_get_id)
return;

if (config->percore_show_thread)
Expand Down

0 comments on commit c0c652f

Please sign in to comment.