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]
Message-ID: <20220705184805.2619caca@kernel.org>
Date:   Tue, 5 Jul 2022 18:48:05 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Liang He <windhl@....com>
Cc:     davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
        netdev@...r.kernel.org
Subject: Re: [PATCH] ftgmac100: Hold reference returned by
 of_get_child_by_name()

On Mon,  4 Jul 2022 23:18:19 +0800 Liang He wrote:
> In ftgmac100_probe(), we should hold the refernece returned by
> of_get_child_by_name() and use it to call of_node_put() for
> reference balance.
> 
> Signed-off-by: Liang He <windhl@....com>
> ---
>  drivers/net/ethernet/faraday/ftgmac100.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 5231818943c6..e50bd7beb09b 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -1770,7 +1770,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  	int irq;
>  	struct net_device *netdev;
>  	struct ftgmac100 *priv;
> -	struct device_node *np;
> +	struct device_node *np, *child_np;
>  	int err = 0;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1883,7 +1883,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  
>  		/* Display what we found */
>  		phy_attached_info(phy);
> -	} else if (np && !of_get_child_by_name(np, "mdio")) {
> +	} else if (np && !(child_np = of_get_child_by_name(np, "mdio"))) {
>  		/* Support legacy ASPEED devicetree descriptions that decribe a
>  		 * MAC with an embedded MDIO controller but have no "mdio"
>  		 * child node. Automatically scan the MDIO bus for available
> @@ -1901,6 +1901,8 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  		}
>  
>  	}
> +	if (child_np)
> +		of_node_put(child_np);

Since we don't care about the value of the node we should add a helper
which checks for presence of the node and releases the reference,
rather than have to do that in this large function.

Please also add a Fixes tag.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ