linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] perf metrics: Avoid segv if default metricgroup isn't set
@ 2023-12-04 18:23 Ian Rogers
  2023-12-04 18:23 ` [PATCH v1 2/2] perf vendor events arm64: Fix default AmpereOne metrics Ian Rogers
  2023-12-04 22:44 ` [PATCH v1 1/2] perf metrics: Avoid segv if default metricgroup isn't set Ilkka Koskinen
  0 siblings, 2 replies; 12+ messages in thread
From: Ian Rogers @ 2023-12-04 18:23 UTC (permalink / raw)
  To: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Ilkka Koskinen, Kan Liang, Kajol Jain,
	linux-arm-kernel, linux-perf-users, linux-kernel

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: 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/metricgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 0484736d9fe4..ca3e0404f187 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -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);
-- 
2.43.0.rc2.451.g8631bc7472-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-12-05 19:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 18:23 [PATCH v1 1/2] perf metrics: Avoid segv if default metricgroup isn't set Ian Rogers
2023-12-04 18:23 ` [PATCH v1 2/2] perf vendor events arm64: Fix default AmpereOne metrics Ian Rogers
2023-12-04 22:44 ` [PATCH v1 1/2] perf metrics: Avoid segv if default metricgroup isn't set Ilkka Koskinen
2023-12-05  3:33   ` Namhyung Kim
2023-12-05  4:25     ` Ian Rogers
2023-12-05 15:51     ` Arnaldo Carvalho de Melo
2023-12-05 17:24       ` Namhyung Kim
2023-12-05 18:48         ` Arnaldo Carvalho de Melo
2023-12-05 19:10           ` Namhyung Kim
2023-12-05 19:14             ` Ian Rogers
2023-12-05 19:17               ` Namhyung Kim
2023-12-05 15:19   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).