Skip to content

Commit

Permalink
perf metrics: Fix segv for metrics with no events
Browse files Browse the repository at this point in the history
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: a59fb79 ("perf metrics: Compute unmerged uncore metrics individually")
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240224011420.3066322-2-irogers@google.com
  • Loading branch information
Ian Rogers authored and Namhyung Kim committed Feb 29, 2024
1 parent d4be39c commit 97b6b4a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/util/metricgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 97b6b4a

Please sign in to comment.