[PATCH 4/5] perf stat: Avoid segv if core.user_cpus isn't set.
Arnaldo Carvalho de Melo
acme at kernel.org
Mon Mar 28 13:32:31 PDT 2022
Em Sun, Mar 27, 2022 at 11:24:13PM -0700, Ian Rogers escreveu:
> 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.
Applying this one after changing user_cpus back to cpus as this is a fix
independent of this patchset.
In the future, please try to have such patches at the beginning of the
series, so that they can get cherry-picked more easily.
- Arnaldo
> Signed-off-by: Ian Rogers <irogers at google.com>
> ---
> tools/perf/builtin-stat.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 5bee529f7656..ecd5cf4fd872 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -1472,7 +1472,10 @@ static int perf_stat_init_aggr_mode(void)
> * taking the highest cpu number to be the size of
> * the aggregation translate cpumap.
> */
> - nr = perf_cpu_map__max(evsel_list->core.user_cpus).cpu;
> + if (evsel_list->core.user_cpus)
> + nr = perf_cpu_map__max(evsel_list->core.user_cpus).cpu;
> + else
> + nr = 0;
> stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr + 1);
> return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
> }
> --
> 2.35.1.1021.g381101b075-goog
--
- Arnaldo
More information about the linux-arm-kernel
mailing list