diff options
author | Will Deacon <will.deacon@arm.com> | 2015-05-14 19:07:44 +0200 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-05-18 22:51:28 +0200 |
commit | 8d2812849acbc13c07bdad8a0a55a342ec1ce3a4 (patch) | |
tree | 5d16f21c6dad3e360ecc303ed2d9772fdc1ea4d8 /arch | |
parent | ARM: fix missing syscall trace exit (diff) | |
download | linux-8d2812849acbc13c07bdad8a0a55a342ec1ce3a4.tar.xz linux-8d2812849acbc13c07bdad8a0a55a342ec1ce3a4.zip |
ARM: 8357/1: perf: fix memory leak when probing PMU PPIs
Commit 338d9dd3e2ae ("ARM: 8351/1: perf: don't warn about missing
interrupt-affinity property for PPIs") added a check for PPIs so that
we avoid parsing the interrupt-affinity property for these naturally
affine interrupts.
Unfortunately, this check can trigger an early (successful) return and
we will leak the irqs array. This patch fixes the issue by reordering
the code so that the check is performed before any independent
allocation.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kernel/perf_event_cpu.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c index 213919ba326f..3b8c2833c537 100644 --- a/arch/arm/kernel/perf_event_cpu.c +++ b/arch/arm/kernel/perf_event_cpu.c @@ -304,16 +304,17 @@ static int probe_current_pmu(struct arm_pmu *pmu) static int of_pmu_irq_cfg(struct platform_device *pdev) { int i, irq; - int *irqs = kcalloc(pdev->num_resources, sizeof(*irqs), GFP_KERNEL); - - if (!irqs) - return -ENOMEM; + int *irqs; /* Don't bother with PPIs; they're already affine */ irq = platform_get_irq(pdev, 0); if (irq >= 0 && irq_is_percpu(irq)) return 0; + irqs = kcalloc(pdev->num_resources, sizeof(*irqs), GFP_KERNEL); + if (!irqs) + return -ENOMEM; + for (i = 0; i < pdev->num_resources; ++i) { struct device_node *dn; int cpu; |