summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2011-12-02 18:16:01 +0100
committerNicolas Pitre <nicolas.pitre@linaro.org>2011-12-15 09:24:51 -0500
commit2150f72fe35397cc6d6ce39866bd0462cfbcc916 (patch)
tree8689b33de38869fea12252656d5db301f49d18f7
parentf8489660a18c1865ee4f4a47593fd2dcf67a4e88 (diff)
ARM: 7185/1: perf: don't assign platform_device on unsupported CPUslinux-linaro-3.1-2011.12-1
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> (cherry picked from commit 6bd054096dce061560cee0e016e292e588dc438f)
-rw-r--r--arch/arm/kernel/perf_event.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 5e455094df8..eacc1b09060 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/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)
{
+ if (!cpu_pmu)
+ return -ENODEV;
+
cpu_pmu->plat_device = pdev;
return 0;
}