lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 Jun 2022 09:00:52 +0000
From:   <Claudiu.Beznea@...rochip.com>
To:     <linmq006@...il.com>, <Nicolas.Ferre@...rochip.com>,
        <alexandre.belloni@...tlin.com>, <Mihai.Sain@...rochip.com>,
        <sudeep.holla@....com>, <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers: soc: atmel: Fix refcount leak in
 atmel_soc_device_init

On 05.06.2022 11:40, Miaoqian Lin wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> of_find_node_by_path() returns a node pointer with refcount incremented,
> we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> 
> Fixes: 960ddf70cc11 ("drivers: soc: atmel: Avoid calling at91_soc_init on non AT91 SoCs")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---
>  drivers/soc/atmel/soc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/atmel/soc.c b/drivers/soc/atmel/soc.c
> index b2d365ae0282..46dfa24c52fb 100644
> --- a/drivers/soc/atmel/soc.c
> +++ b/drivers/soc/atmel/soc.c
> @@ -369,10 +369,13 @@ static int __init atmel_soc_device_init(void)
>  {
>         struct device_node *np = of_find_node_by_path("/");
> 

What about having it like this:
	const struct of_device_id *of_id;

	of_id = of_match_node(at91_soc_allowed_list, np);
	of_node_put(np);
	if (!of_id)
		return 0;

And everything else the same?

> -       if (!of_match_node(at91_soc_allowed_list, np))
> +       if (!of_match_node(at91_soc_allowed_list, np)) {
> +               of_node_put(np);
>                 return 0;
> +       }
> 
>         at91_soc_init(socs);
> +       of_node_put(np);
> 
>         return 0;
>  }
> --
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ