[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20171206144115.15097-24-acme@kernel.org>
Date: Wed, 6 Dec 2017 11:41:02 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
Ganapatrao Kulkarni <ganapatrao.kulkarni@...ium.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Catalin Marinas <catalin.marinas@....com>,
Ganapatrao Kulkarni <gklkml16@...il.com>,
Jayachandran C <jnair@...iumnetworks.com>,
Jonathan Cameron <jonathan.cameron@...wei.com>,
Mark Rutland <mark.rutland@....com>,
Peter Zijlstra <peterz@...radead.org>,
Robert Richter <robert.richter@...ium.com>,
Shaokun Zhang <zhangshaokun@...ilicon.com>,
Will Deacon <will.deacon@....com>,
linux-arm-kernel@...ts.infradead.org,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH 23/36] perf pmu: Add check for valid cpuid in perf_pmu__find_map()
From: Ganapatrao Kulkarni <ganapatrao.kulkarni@...ium.com>
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 <ganapatrao.kulkarni@...ium.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Catalin Marinas <catalin.marinas@....com>
Cc: Ganapatrao Kulkarni <gklkml16@...il.com>
Cc: Jayachandran C <jnair@...iumnetworks.com>
Cc: Jonathan Cameron <jonathan.cameron@...wei.com>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Robert Richter <robert.richter@...ium.com>
Cc: Shaokun Zhang <zhangshaokun@...ilicon.com>
Cc: Will Deacon <will.deacon@....com>
Cc: linux-arm-kernel@...ts.infradead.org
Link: http://lkml.kernel.org/r/20171016183222.25750-6-ganapatrao.kulkarni@cavium.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
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 732ff579ec65..8b7c151579c0 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -601,6 +601,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.13.6
Powered by blists - more mailing lists