linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put
@ 2019-03-05 11:32 Wen Yang
  2019-03-05 11:32 ` [PATCH 2/4] ARM: mvebu: " Wen Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Wen Yang @ 2019-03-05 11:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Florian Fainelli, Ray Jui, Scott Branden,
	bcm-kernel-feedback-list, Russell King, Brian Norris,
	Gregory Fong, linux-arm-kernel

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/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>
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: Brian Norris <computersforpeace@gmail.com>
Cc: Gregory Fong <gregory.0xf0@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm/mach-bcm/bcm63xx_smp.c     | 1 +
 arch/arm/mach-bcm/platsmp-brcmstb.c | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-bcm/bcm63xx_smp.c b/arch/arm/mach-bcm/bcm63xx_smp.c
index f5fb10b..1cb4ce8 100644
--- a/arch/arm/mach-bcm/bcm63xx_smp.c
+++ b/arch/arm/mach-bcm/bcm63xx_smp.c
@@ -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:
diff --git a/arch/arm/mach-bcm/platsmp-brcmstb.c b/arch/arm/mach-bcm/platsmp-brcmstb.c
index 1237996..4555f21 100644
--- a/arch/arm/mach-bcm/platsmp-brcmstb.c
+++ b/arch/arm/mach-bcm/platsmp-brcmstb.c
@@ -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)
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put Wen Yang
@ 2019-03-05 11:32 ` Wen Yang
  2019-04-21 17:24   ` Gregory CLEMENT
  2019-03-05 11:32 ` [PATCH 3/4] ARM: rockchip: " Wen Yang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Wen Yang @ 2019-03-05 11:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Jason Cooper, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Russell King, linux-arm-kernel

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-mvebu/pm-board.c:135:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 88, but without a corresponding object release within this functio

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm/mach-mvebu/pm-board.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c
index db17121..1e2c17c 100644
--- a/arch/arm/mach-mvebu/pm-board.c
+++ b/arch/arm/mach-mvebu/pm-board.c
@@ -79,7 +79,7 @@ static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
 static int __init mvebu_armada_pm_init(void)
 {
 	struct device_node *np;
-	struct device_node *gpio_ctrl_np;
+	struct device_node *gpio_ctrl_np = NULL;
 	int ret = 0, i;
 
 	if (!of_machine_is_compatible("marvell,axp-gp"))
@@ -126,18 +126,23 @@ static int __init mvebu_armada_pm_init(void)
 			goto out;
 		}
 
+		if(gpio_ctrl_np)
+			of_node_put(gpio_ctrl_np);
 		gpio_ctrl_np = args.np;
 		pic_raw_gpios[i] = args.args[0];
 	}
 
 	gpio_ctrl = of_iomap(gpio_ctrl_np, 0);
-	if (!gpio_ctrl)
-		return -ENOMEM;
+	if (!gpio_ctrl) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	mvebu_pm_suspend_init(mvebu_armada_pm_enter);
 
 out:
 	of_node_put(np);
+	of_node_put(gpio_ctrl_np);
 	return ret;
 }
 
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] ARM: rockchip: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put Wen Yang
  2019-03-05 11:32 ` [PATCH 2/4] ARM: mvebu: " Wen Yang
@ 2019-03-05 11:32 ` Wen Yang
  2019-04-23 17:54   ` Heiko Stuebner
  2019-03-05 11:32 ` [PATCH 4/4] ARM: sunxi: " Wen Yang
  2019-03-06  3:14 ` [PATCH 1/4] ARM: brcmstb: " Florian Fainelli
  3 siblings, 1 reply; 8+ messages in thread
From: Wen Yang @ 2019-03-05 11:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Russell King, Heiko Stuebner,
	linux-arm-kernel, linux-rockchip

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-rockchip/platsmp.c:250:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:260:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:263:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm/mach-rockchip/platsmp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-rockchip/platsmp.c b/arch/arm/mach-rockchip/platsmp.c
index f93d64e..6cb4b21 100644
--- a/arch/arm/mach-rockchip/platsmp.c
+++ b/arch/arm/mach-rockchip/platsmp.c
@@ -245,6 +245,7 @@ static int __init rockchip_smp_prepare_pmu(void)
 	}
 
 	pmu_base = of_iomap(node, 0);
+	of_node_put(node);
 	if (!pmu_base) {
 		pr_err("%s: could not map pmu registers\n", __func__);
 		return -ENOMEM;
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] ARM: sunxi: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put Wen Yang
  2019-03-05 11:32 ` [PATCH 2/4] ARM: mvebu: " Wen Yang
  2019-03-05 11:32 ` [PATCH 3/4] ARM: rockchip: " Wen Yang
@ 2019-03-05 11:32 ` Wen Yang
  2019-03-05 11:59   ` Maxime Ripard
  2019-03-06  3:14 ` [PATCH 1/4] ARM: brcmstb: " Florian Fainelli
  3 siblings, 1 reply; 8+ messages in thread
From: Wen Yang @ 2019-03-05 11:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, Wen Yang, Maxime Ripard, Chen-Yu Tsai, Russell King,
	linux-arm-kernel

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-sunxi/mc_smp.c:110:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 97, but without a corresponding object release within this functio
./arch/arm/mach-sunxi/platsmp.c:138:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 129, but without a corresponding object release within this function

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org (open list)
---
 arch/arm/mach-sunxi/mc_smp.c  | 5 ++++-
 arch/arm/mach-sunxi/platsmp.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/mc_smp.c b/arch/arm/mach-sunxi/mc_smp.c
index b4037b6..239084c 100644
--- a/arch/arm/mach-sunxi/mc_smp.c
+++ b/arch/arm/mach-sunxi/mc_smp.c
@@ -89,6 +89,7 @@ static bool sunxi_core_is_cortex_a15(unsigned int core, unsigned int cluster)
 {
 	struct device_node *node;
 	int cpu = cluster * SUNXI_CPUS_PER_CLUSTER + core;
+	bool is_compatible;
 
 	node = of_cpu_device_node_get(cpu);
 
@@ -107,7 +108,9 @@ static bool sunxi_core_is_cortex_a15(unsigned int core, unsigned int cluster)
 		return false;
 	}
 
-	return of_device_is_compatible(node, "arm,cortex-a15");
+	is_compatible = of_device_is_compatible(node, "arm,cortex-a15");
+	of_node_put(node);
+	return is_compatible;
 }
 
 static int sunxi_cpu_power_switch_set(unsigned int cpu, unsigned int cluster,
diff --git a/arch/arm/mach-sunxi/platsmp.c b/arch/arm/mach-sunxi/platsmp.c
index c842209..bdde9ef 100644
--- a/arch/arm/mach-sunxi/platsmp.c
+++ b/arch/arm/mach-sunxi/platsmp.c
@@ -135,6 +135,7 @@ static void __init sun8i_smp_prepare_cpus(unsigned int max_cpus)
 	}
 
 	prcm_membase = of_iomap(node, 0);
+	of_node_put(node);
 	if (!prcm_membase) {
 		pr_err("Couldn't map A23 PRCM registers\n");
 		return;
@@ -148,6 +149,7 @@ static void __init sun8i_smp_prepare_cpus(unsigned int max_cpus)
 	}
 
 	cpucfg_membase = of_iomap(node, 0);
+	of_node_put(node);
 	if (!cpucfg_membase)
 		pr_err("Couldn't map A23 CPU config registers\n");
 
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] ARM: sunxi: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 ` [PATCH 4/4] ARM: sunxi: " Wen Yang
@ 2019-03-05 11:59   ` Maxime Ripard
  0 siblings, 0 replies; 8+ messages in thread
From: Maxime Ripard @ 2019-03-05 11:59 UTC (permalink / raw)
  To: Wen Yang
  Cc: linux-kernel, wang.yi59, Chen-Yu Tsai, Russell King, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1057 bytes --]

On Tue, Mar 05, 2019 at 07:32:57PM +0800, Wen Yang wrote:
> 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-sunxi/mc_smp.c:110:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 97, but without a corresponding object release within this functio
> ./arch/arm/mach-sunxi/platsmp.c:138:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 129, but without a corresponding object release within this function
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Maxime Ripard <maxime.ripard@bootlin.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org (open list)

Applied, thanks!
Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put Wen Yang
                   ` (2 preceding siblings ...)
  2019-03-05 11:32 ` [PATCH 4/4] ARM: sunxi: " Wen Yang
@ 2019-03-06  3:14 ` Florian Fainelli
  3 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2019-03-06  3:14 UTC (permalink / raw)
  To: Wen Yang, linux-kernel
  Cc: wang.yi59, Florian Fainelli, Ray Jui, Scott Branden,
	bcm-kernel-feedback-list, Russell King, Brian Norris,
	Gregory Fong, linux-arm-kernel



On 3/5/2019 3:32 AM, Wen Yang wrote:
> 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/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.


I would actually lump that in your [PATCH v2 02/15] ARM: bcm: fix a
leaked reference by adding missing of_node_put patch since the subject
of that one is correct.

Thanks!
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 ` [PATCH 2/4] ARM: mvebu: " Wen Yang
@ 2019-04-21 17:24   ` Gregory CLEMENT
  0 siblings, 0 replies; 8+ messages in thread
From: Gregory CLEMENT @ 2019-04-21 17:24 UTC (permalink / raw)
  To: Wen Yang, linux-kernel
  Cc: wang.yi59, Wen Yang, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Russell King, linux-arm-kernel

Hi Wen Yang,

> 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-mvebu/pm-board.c:135:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 88, but without a corresponding object release within this functio
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org

Applied on mvebu/arm

Thanks,

Gregory

> ---
>  arch/arm/mach-mvebu/pm-board.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c
> index db17121..1e2c17c 100644
> --- a/arch/arm/mach-mvebu/pm-board.c
> +++ b/arch/arm/mach-mvebu/pm-board.c
> @@ -79,7 +79,7 @@ static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
>  static int __init mvebu_armada_pm_init(void)
>  {
>  	struct device_node *np;
> -	struct device_node *gpio_ctrl_np;
> +	struct device_node *gpio_ctrl_np = NULL;
>  	int ret = 0, i;
>  
>  	if (!of_machine_is_compatible("marvell,axp-gp"))
> @@ -126,18 +126,23 @@ static int __init mvebu_armada_pm_init(void)
>  			goto out;
>  		}
>  
> +		if(gpio_ctrl_np)
> +			of_node_put(gpio_ctrl_np);
>  		gpio_ctrl_np = args.np;
>  		pic_raw_gpios[i] = args.args[0];
>  	}
>  
>  	gpio_ctrl = of_iomap(gpio_ctrl_np, 0);
> -	if (!gpio_ctrl)
> -		return -ENOMEM;
> +	if (!gpio_ctrl) {
> +		ret = -ENOMEM;
> +		goto out;
> +	}
>  
>  	mvebu_pm_suspend_init(mvebu_armada_pm_enter);
>  
>  out:
>  	of_node_put(np);
> +	of_node_put(gpio_ctrl_np);
>  	return ret;
>  }
>  
> -- 
> 2.9.5
>

-- 
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] ARM: rockchip: fix a leaked reference by adding missing of_node_put
  2019-03-05 11:32 ` [PATCH 3/4] ARM: rockchip: " Wen Yang
@ 2019-04-23 17:54   ` Heiko Stuebner
  0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stuebner @ 2019-04-23 17:54 UTC (permalink / raw)
  To: Wen Yang
  Cc: linux-kernel, wang.yi59, Russell King, linux-arm-kernel, linux-rockchip

Am Dienstag, 5. März 2019, 12:32:56 CEST schrieb Wen Yang:
> 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-rockchip/platsmp.c:250:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:260:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:263:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-rockchip@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org

applied for 5.2 after adapting the patch subject a little bit

Thanks
Heiko



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-04-23 17:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-05 11:32 [PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put Wen Yang
2019-03-05 11:32 ` [PATCH 2/4] ARM: mvebu: " Wen Yang
2019-04-21 17:24   ` Gregory CLEMENT
2019-03-05 11:32 ` [PATCH 3/4] ARM: rockchip: " Wen Yang
2019-04-23 17:54   ` Heiko Stuebner
2019-03-05 11:32 ` [PATCH 4/4] ARM: sunxi: " Wen Yang
2019-03-05 11:59   ` Maxime Ripard
2019-03-06  3:14 ` [PATCH 1/4] ARM: brcmstb: " Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).