This patch fixes a NULL-dereference introduced by commit 457520e ("arm: pmu: support pmu/perf on OMAP4").
Some platforms (e.g. vexpress) neither need nor have an instance of arm_pmu_platdata (plat). Perf support on these platforms was broken by the original commit.
This patch adds a check for plat before dereferencing any fields.
Signed-off-by: Mark Rutland mark.rutland@arm.com Cc: Avik Sil avik.sil@linaro.org Cc: Nicolas Pitre nicolas.pitre@linaro.org --- arch/arm/kernel/perf_event.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index 1a0d6af..5d5f300 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c @@ -426,15 +426,16 @@ armpmu_reserve_hardware(void) pr_warning("unable to request IRQ%d for ARM perf " "counters\n", irq); break; - } else if (plat->enable_irq) + } else if (plat && plat->enable_irq) { plat->enable_irq(irq); + } }
if (err) { for (i = i - 1; i >= 0; --i) { irq = platform_get_irq(pmu_device, i); if (irq >= 0) { - if (plat->disable_irq) + if (plat && plat->disable_irq) plat->disable_irq(irq); free_irq(irq, NULL); } @@ -456,7 +457,7 @@ armpmu_release_hardware(void) for (i = pmu_device->num_resources - 1; i >= 0; --i) { irq = platform_get_irq(pmu_device, i); if (irq >= 0) { - if (plat->disable_irq) + if (plat && plat->disable_irq) plat->disable_irq(irq); free_irq(irq, NULL); }