[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877ebn8e66.fsf@FE-laptop>
Date: Sun, 21 Apr 2019 19:24:17 +0200
From: Gregory CLEMENT <gregory.clement@...tlin.com>
To: Wen Yang <wen.yang99@....com.cn>, linux-kernel@...r.kernel.org
Cc: wang.yi59@....com.cn, Wen Yang <wen.yang99@....com.cn>,
Jason Cooper <jason@...edaemon.net>,
Andrew Lunn <andrew@...n.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
Russell King <linux@...linux.org.uk>,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 2/4] ARM: mvebu: fix a leaked reference by adding missing of_node_put
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@....com.cn>
> Cc: Jason Cooper <jason@...edaemon.net>
> Cc: Andrew Lunn <andrew@...n.ch>
> Cc: Gregory Clement <gregory.clement@...tlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
> Cc: Russell King <linux@...linux.org.uk>
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-kernel@...r.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
Powered by blists - more mailing lists