diff options
author | Will Deacon <will.deacon@arm.com> | 2011-11-22 13:01:46 -0500 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2011-11-22 13:01:46 -0500 |
commit | e5a21327644adba32816f74a415114d11c57f2e9 (patch) | |
tree | 81264b2c3ba630e7f5d4f43f9ad99e6268515dad | |
parent | bce34d14428d35d9a06ddc10cd46ecef311764c9 (diff) |
ARM: perf: check that we have a platform device when reserving PMU
Attempting to use a hardware counter on a platform with a supported PMU
but where the platform_device (defining the interrupts) has not been
registered results in a NULL pointer dereference.
This patch fixes the problem by checking that we actually have a platform
device registered before attempting to grab the interrupts.
Reported-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | arch/arm/kernel/perf_event.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index e508066d3d64..c475379199b1 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c | |||
@@ -402,6 +402,9 @@ armpmu_reserve_hardware(struct arm_pmu *armpmu) | |||
402 | int i, err, irq, irqs; | 402 | int i, err, irq, irqs; |
403 | struct platform_device *pmu_device = armpmu->plat_device; | 403 | struct platform_device *pmu_device = armpmu->plat_device; |
404 | 404 | ||
405 | if (!pmu_device) | ||
406 | return -ENODEV; | ||
407 | |||
405 | err = reserve_pmu(armpmu->type); | 408 | err = reserve_pmu(armpmu->type); |
406 | if (err) { | 409 | if (err) { |
407 | pr_warning("unable to reserve pmu\n"); | 410 | pr_warning("unable to reserve pmu\n"); |