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: <20191214202745.649bbed2@cakuba.netronome.com>
Date:   Sat, 14 Dec 2019 20:27:45 -0800
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     Russell King <rmk+kernel@...linux.org.uk>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Milind Parab <mparab@...ence.com>,
        "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next] net: phylink: propagate phy_attach_direct()
 return code

On Thu, 12 Dec 2019 17:16:12 +0000, Russell King wrote:
> of_phy_attach() hides the return value of phy_attach_direct(), forcing
> us to return a "generic" ENODEV error code that is indistinguishable
> from the lack-of-phy-property case.
> 
> Switch to using of_phy_find_device() to find the PHY device, and then
> propagating any phy_attach_direct() error back to the caller.
> 
> Link: https://lore.kernel.org/lkml/20191210113829.GT25745@shell.armlinux.org.uk
> Signed-off-by: Russell King <rmk+kernel@...linux.org.uk>

Applied thanks, the ref counting is not entirely obvious to a layman.
In your reply to Milind you said he can immediately of_node_put()
because the phy_dev is never deferenced in his code, but here it looks
like it is actually - the reference used to be given up after attach is
done, now its given up before attach_direct is called.

But I don't know how the refcounting here works, so applied, and on the
off chance the code is wrong follow up will be fine.

> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index f7c660bf99d1..8d20cf3ba0b7 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -859,14 +859,17 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
>  		return 0;
>  	}
>  
> -	phy_dev = of_phy_attach(pl->netdev, phy_node, flags,
> -				pl->link_interface);
> +	phy_dev = of_phy_find_device(phy_node);
>  	/* We're done with the phy_node handle */
>  	of_node_put(phy_node);
> -
>  	if (!phy_dev)
>  		return -ENODEV;
>  
> +	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
> +				pl->link_interface);
> +	if (ret)
> +		return ret;
> +
>  	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
>  	if (ret)
>  		phy_detach(phy_dev);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ