瀏覽代碼

ARM: 7185/1: 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.

Reported-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Will Deacon 13 年之前
父節點
當前提交
6bd054096d
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      arch/arm/kernel/perf_event.c

+ 3 - 0
arch/arm/kernel/perf_event.c

@@ -640,6 +640,9 @@ static struct platform_device_id armpmu_plat_device_ids[] = {
 
 
 static int __devinit armpmu_device_probe(struct platform_device *pdev)
 static int __devinit armpmu_device_probe(struct platform_device *pdev)
 {
 {
+	if (!cpu_pmu)
+		return -ENODEV;
+
 	cpu_pmu->plat_device = pdev;
 	cpu_pmu->plat_device = pdev;
 	return 0;
 	return 0;
 }
 }