aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2015-05-14 13:07:44 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-05-18 16:51:28 -0400
commit8d2812849acbc13c07bdad8a0a55a342ec1ce3a4 (patch)
tree5d16f21c6dad3e360ecc303ed2d9772fdc1ea4d8
parent1b97937246d8b97c0760d16d8992c7937bdf5e6a (diff)
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>
-rw-r--r--arch/arm/kernel/perf_event_cpu.c9
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)
304static int of_pmu_irq_cfg(struct platform_device *pdev) 304static int of_pmu_irq_cfg(struct platform_device *pdev)
305{ 305{
306 int i, irq; 306 int i, irq;
307 int *irqs = kcalloc(pdev->num_resources, sizeof(*irqs), GFP_KERNEL); 307 int *irqs;
308
309 if (!irqs)
310 return -ENOMEM;
311 308
312 /* Don't bother with PPIs; they're already affine */ 309 /* Don't bother with PPIs; they're already affine */
313 irq = platform_get_irq(pdev, 0); 310 irq = platform_get_irq(pdev, 0);
314 if (irq >= 0 && irq_is_percpu(irq)) 311 if (irq >= 0 && irq_is_percpu(irq))
315 return 0; 312 return 0;
316 313
314 irqs = kcalloc(pdev->num_resources, sizeof(*irqs), GFP_KERNEL);
315 if (!irqs)
316 return -ENOMEM;
317
317 for (i = 0; i < pdev->num_resources; ++i) { 318 for (i = 0; i < pdev->num_resources; ++i) {
318 struct device_node *dn; 319 struct device_node *dn;
319 int cpu; 320 int cpu;