Skip to content

Commit de3d0f1

Browse files
Ganapatrao Kulkarniacmel
authored andcommitted
perf pmu: Add check for valid cpuid in perf_pmu__find_map()
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 <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Ganapatrao Kulkarni <[email protected]> Cc: Jayachandran C <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Robert Richter <[email protected]> Cc: Shaokun Zhang <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d396422 commit de3d0f1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/perf/util/pmu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,12 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
601601
char *cpuid = perf_pmu__getcpuid(pmu);
602602
int i;
603603

604+
/* on some platforms which uses cpus map, cpuid can be NULL for
605+
* PMUs other than CORE PMUs.
606+
*/
607+
if (!cpuid)
608+
return NULL;
609+
604610
i = 0;
605611
for (;;) {
606612
map = &pmu_events_map[i++];

0 commit comments

Comments
 (0)