]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ARM: bcm: fix a leaked reference by adding missing of_node_put
authorWen Yang <wen.yang99@zte.com.cn>
Tue, 5 Mar 2019 11:33:53 +0000 (19:33 +0800)
committerFlorian Fainelli <f.fainelli@gmail.com>
Mon, 20 May 2019 16:34:26 +0000 (09:34 -0700)
The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./arch/arm/mach-bcm/board_bcm281xx.c:43:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 35, but without a corresponding object release within this function.
./arch/arm/mach-bcm/platsmp-brcmstb.c:337:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 329, but without a corresponding object release within this function.
./arch/arm/mach-bcm/platsmp-brcmstb.c:341:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 329, but without a corresponding object release within this functio
./arch/arm/mach-bcm/bcm63xx_smp.c:150:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 130, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
arch/arm/mach-bcm/bcm63xx_smp.c
arch/arm/mach-bcm/board_bcm281xx.c
arch/arm/mach-bcm/platsmp-brcmstb.c

index f5fb10b4376f7391bc93f5c3a44edad3612c9864..1cb4ce812a8412bd2223bd8dd3d4428041f7c40d 100644 (file)
@@ -142,6 +142,7 @@ static int bcm63138_smp_boot_secondary(unsigned int cpu,
         * return
         */
        ret = bcm63xx_pmb_power_on_cpu(dn);
+       of_node_put(dn);
        if (ret)
                goto out;
 out:
index b81bb386951dc2b414c0df526d720480afcf701a..1238ac801530ed08f98285dffa600543dd38cdbd 100644 (file)
@@ -38,6 +38,7 @@ static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)
                return;
        }
        base = of_iomap(np_wdog, 0);
+       of_node_put(np_wdog);
        if (!base) {
                pr_emerg("Couldn't map brcm,kona-wdt\n");
                return;
index 12379960e982de5ea427bfee05a28d05a78af680..4555f21e70775ffe4c3d5c32ea6a4bf1ed0981f1 100644 (file)
@@ -334,11 +334,14 @@ static void __init brcmstb_cpu_ctrl_setup(unsigned int max_cpus)
 
        rc = setup_hifcpubiuctrl_regs(np);
        if (rc)
-               return;
+               goto out_put_node;
 
        rc = setup_hifcont_regs(np);
        if (rc)
-               return;
+               goto out_put_node;
+
+out_put_node:
+       of_node_put(np);
 }
 
 static int brcmstb_boot_secondary(unsigned int cpu, struct task_struct *idle)