Thread (23 messages) 23 messages, 6 authors, 2017-12-07
STALE3118d

[PATCH v9 5/5] perf utils: add check for valid cpuid in function perf_pmu__find_map

From: Ganapatrao Kulkarni <hidden>
Date: 2017-10-16 18:33:22
Also in: lkml
Subsystem: performance events subsystem, the rest · Maintainers: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds

On some platforms(arm/arm64) which uses cpus map to get corresponding
cpuid string, cpuid can be NULL for PMUs other than CORE PMUs.
Adding check for NULL cpuid in function perf_pmu__find_map to
avoid segmentation fault.

Signed-off-by: Ganapatrao Kulkarni <redacted>
---
 tools/perf/util/pmu.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 9110718..569fb0c 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -567,6 +567,12 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	char *cpuid = perf_pmu__getcpuid(pmu);
 	int i;
 
+	/* on some platforms which uses cpus map, cpuid can be NULL for
+	 * PMUs other than CORE PMUs.
+	 */
+	if (!cpuid)
+		return NULL;
+
 	i = 0;
 	for (;;) {
 		map = &pmu_events_map[i++];
-- 
2.9.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help