All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Wen Yang <wen.yang99@zte.com.cn>, linux-kernel@vger.kernel.org
Cc: wang.yi59@zte.com.cn, Andrew Lunn <andrew@lunn.ch>,
	Jason Cooper <jason@lakedaemon.net>,
	Russell King <linux@armlinux.org.uk>,
	Wen Yang <wen.yang99@zte.com.cn>,
	linux-arm-kernel@lists.infradead.org,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: Re: [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put
Date: Sun, 21 Apr 2019 19:24:17 +0200	[thread overview]
Message-ID: <877ebn8e66.fsf@FE-laptop> (raw)
In-Reply-To: <1551785577-45896-2-git-send-email-wen.yang99@zte.com.cn>

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Wen Yang <wen.yang99@zte.com.cn>, linux-kernel@vger.kernel.org
Cc: wang.yi59@zte.com.cn, Wen Yang <wen.yang99@zte.com.cn>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put
Date: Sun, 21 Apr 2019 19:24:17 +0200	[thread overview]
Message-ID: <877ebn8e66.fsf@FE-laptop> (raw)
In-Reply-To: <1551785577-45896-2-git-send-email-wen.yang99@zte.com.cn>

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

  reply	other threads:[~2019-04-21 17:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-03-05 11:32 ` [PATCH 2/4] ARM: mvebu: " Wen Yang
2019-03-05 11:32   ` Wen Yang
2019-04-21 17:24   ` Gregory CLEMENT [this message]
2019-04-21 17:24     ` Gregory CLEMENT
2019-03-05 11:32 ` [PATCH 3/4] ARM: rockchip: " Wen Yang
2019-03-05 11:32   ` Wen Yang
2019-04-23 17:54   ` Heiko Stuebner
2019-04-23 17:54     ` Heiko Stuebner
2019-03-05 11:32 ` [PATCH 4/4] ARM: sunxi: " Wen Yang
2019-03-05 11:32   ` Wen Yang
2019-03-05 11:59   ` Maxime Ripard
2019-03-05 11:59     ` Maxime Ripard
2019-03-06  3:14 ` [PATCH 1/4] ARM: brcmstb: " Florian Fainelli
2019-03-06  3:14   ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877ebn8e66.fsf@FE-laptop \
    --to=gregory.clement@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=wang.yi59@zte.com.cn \
    --cc=wen.yang99@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.