Skip to content

Commit e2b005d

Browse files
captain5050namhyung
authored andcommitted
perf metrics: Avoid segv if default metricgroup isn't set
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]>
1 parent 57686a7 commit e2b005d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/util/metricgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static struct metric *metric__new(const struct pmu_metric *pm,
225225

226226
m->pmu = pm->pmu ?: "cpu";
227227
m->metric_name = pm->metric_name;
228-
m->default_metricgroup_name = pm->default_metricgroup_name;
228+
m->default_metricgroup_name = pm->default_metricgroup_name ?: "";
229229
m->modifier = NULL;
230230
if (modifier) {
231231
m->modifier = strdup(modifier);

0 commit comments

Comments
 (0)