[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    ARM: 8357/1: perf: fix memory leak when probing PMU PPIs
From:       "Linux Kernel Mailing List" <linux-kernel () vger ! kernel ! org>
Date:       2015-05-31 19:50:59
Message-ID: 20150531195059.729B3660CC4 () gitolite ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/;a=commit;h=8d2812849acbc13c07bdad8a0a55a342ec1ce3a4
Commit:     8d2812849acbc13c07bdad8a0a55a342ec1ce3a4
Parent:     1b97937246d8b97c0760d16d8992c7937bdf5e6a
Refname:    refs/heads/master
Author:     Will Deacon <will.deacon@arm.com>
AuthorDate: Thu May 14 18:07:44 2015 +0100
Committer:  Russell King <rmk+kernel@arm.linux.org.uk>
CommitDate: Mon May 18 21:51:28 2015 +0100

    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>
---
 arch/arm/kernel/perf_event_cpu.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
index 213919b..3b8c283 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;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic