Skip to content

Commit

Permalink
perf metrics: Avoid segv if default metricgroup isn't set
Browse files Browse the repository at this point in the history
A metric is default by having "Default" within its groups. The default
metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmp and perf_stat__print_shadow_stats_metricgroup
that assume it has a value when there is a Default metric group. To
avoid the segv initialize the value to "".

Fixes: 1c0e479 ("perf metrics: Sort the Default metricgroup")
Signed-off-by: Ian Rogers <[email protected]>
Reviewed-and-tested-by: Ilkka Koskinen <[email protected]>
Cc: James Clark <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mike Leach <[email protected]>
Cc: Kajol Jain <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: John Garry <[email protected]>
Cc: [email protected]
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
  • Loading branch information
captain5050 authored and namhyung committed Dec 5, 2023
1 parent 57686a7 commit e2b005d
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 @@ -225,7 +225,7 @@ static struct metric *metric__new(const struct pmu_metric *pm,

m->pmu = pm->pmu ?: "cpu";
m->metric_name = pm->metric_name;
m->default_metricgroup_name = pm->default_metricgroup_name;
m->default_metricgroup_name = pm->default_metricgroup_name ?: "";
m->modifier = NULL;
if (modifier) {
m->modifier = strdup(modifier);
Expand Down

0 comments on commit e2b005d

Please sign in to comment.