Skip to content

Commit 8a96f45

Browse files
captain5050acmel
authored andcommitted
perf stat: Avoid SEGV if core.cpus isn't set
Passing NULL to perf_cpu_map__max doesn't make sense as there is no valid max. Avoid this problem by null checking in perf_stat_init_aggr_mode. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Antonov <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Alexey Bayduraev <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: German Gomez <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Fastabend <[email protected]> Cc: John Garry <[email protected]> Cc: KP Singh <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Riccardo Mancini <[email protected]> Cc: Song Liu <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yonghong Song <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b012b32 commit 8a96f45

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tools/perf/builtin-stat.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,10 @@ static int perf_stat_init_aggr_mode(void)
14721472
* taking the highest cpu number to be the size of
14731473
* the aggregation translate cpumap.
14741474
*/
1475-
nr = perf_cpu_map__max(evsel_list->core.cpus).cpu;
1475+
if (evsel_list->core.cpus)
1476+
nr = perf_cpu_map__max(evsel_list->core.cpus).cpu;
1477+
else
1478+
nr = 0;
14761479
stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr + 1);
14771480
return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
14781481
}

0 commit comments

Comments
 (0)