perf stat-shadow: In prepare_metric fix guard on reading NULL perf_stat_evsel
authorIan Rogers <irogers@google.com>
Tue, 10 Feb 2026 06:03:55 +0000 (22:03 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 10 Feb 2026 12:33:13 +0000 (09:33 -0300)
commit63b320aaac08ba267268ec21a195ce3c82dcb8ab
treeff4cdc3eb5000d29140db2709a68c139a27040ce
parentbc105a8918fd8458ec3a5b947018b0f8059da529
perf stat-shadow: In prepare_metric fix guard on reading NULL perf_stat_evsel

The aggr value is setup to always be non-null creating a redundant
guard for reading from it. Switch to using the perf_stat_evsel (ps)
and narrow the scope of aggr so that it is known valid when used.

Fixes: 3d65f6445fd93e3e ("perf stat-shadow: Read tool events directly")
Reported-by: Andres Freund <andres@anarazel.de>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/stat-shadow.c