Skip to contentSkip to conversation

ARM: perf: don't assign platform_device on unsupported CPUs

PATCH New Will Deacon 1 participant 1 message Dec 2, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: perf: don't assign platform_device on unsupported CPUs

In the unlikely case that a platform registers a PMU platform_device when running on a CPU that is unsupported by perf, we will encounter a NULL dereference when trying to assign the platform_device to the cpu_pmu structure.

This patch checks that the CPU is supported by perf before assigning the platform_device.

---
 arch/arm/kernel/perf_event.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/kernel/perf_event.c +3 -0
index c475379..4e6d1ed 100644
@@ -640,6 +640,9 @@ static struct platform_device_id armpmu_plat_device_ids[] = {
 
 static int __devinit armpmu_device_probe(struct platform_device *pdev)
 {
+	if (!cpu_pmu)
+		return -ENODEV;
+
 	cpu_pmu->plat_device = pdev;
 	return 0;
 }
Signature · 1 line
1.7.4.1