From: Ian Rogers Date: Sat, 24 Feb 2024 01:14:20 +0000 (-0800) Subject: perf metrics: Fix segv for metrics with no events X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=97b6b4ac1c5dd42a473a4f8e775d97476c5da038;p=users%2Fjedix%2Flinux-maple.git perf metrics: Fix segv for metrics with no events A metric may have no events, for example, the transaction metrics on x86 are dependent on there being TSX events. Fix a segv where an evsel of NULL is dereferenced for a metric leader value. Fixes: a59fb796a36b ("perf metrics: Compute unmerged uncore metrics individually") Signed-off-by: Ian Rogers Reviewed-by: Kan Liang Signed-off-by: Namhyung Kim Link: https://lore.kernel.org/r/20240224011420.3066322-2-irogers@google.com --- diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 2d6865c392ef..79ef6095ab28 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -44,7 +44,7 @@ struct metric_event *metricgroup__lookup(struct rblist *metric_events, if (!metric_events) return NULL; - if (evsel->metric_leader) + if (evsel && evsel->metric_leader) me.evsel = evsel->metric_leader; nd = rblist__find(metric_events, &me); if (nd)