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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 12 Jan 2018 10:46:04 +0300
From:   Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To:     Andrew Lunn <andrew@...n.ch>, geert@...ux-m68k.org,
        niklas.cassel@...s.com
Cc:     David Miller <davem@...emloft.net>,
        Russell King <rmk+kernel@....linux.org.uk>,
        Florian Fainelli <f.fainelli@...il.com>,
        netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] net: phy: Have __phy_modify return 0 on success

Hello!

On 1/11/2018 11:55 PM, Andrew Lunn wrote:

> __phy_modify would return the old value of the register before it was
> modified. Thus on success, it does not return 0, but a positive value.
> Thus functions using phy_modify, which is a wrapper around
> __phy_modify, can start returning > 0 on success, rather than 0. As a
> result, breakage has been noticed in various places, where 0 was
> assumed.
> 
> Code inspection does not find any current location where the return of
> the old value is currently used. So have __phy_modify return 0 on
> success. When there is a real need for the old value, either a new
> accessor can be added, or an additional parameter passed.
> 
> Fixes: 2b74e5be17d2 ("net: phy: add phy_modify() accessor")
> Reported-by: Geert Uytterhoeven <geert@...ux-m68k.org>
> Signed-off-by: Andrew Lunn <andrew@...n.ch>
> ---
> 
> Geert, Niklas
> 
> Please can you test this and let me know if it fixes the problems you
> see.
> 
>   drivers/net/phy/phy-core.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
> index e75989ce8850..36cad6b3b96d 100644
> --- a/drivers/net/phy/phy-core.c
> +++ b/drivers/net/phy/phy-core.c
> @@ -336,16 +336,15 @@ EXPORT_SYMBOL(phy_write_mmd);
>    */
>   int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set)
>   {
> -	int ret, res;
> +	int ret;
>   
>   	ret = __phy_read(phydev, regnum);
> -	if (ret >= 0) {
> -		res = __phy_write(phydev, regnum, (ret & ~mask) | set);
> -		if (res < 0)
> -			ret = res;
> -	}
> +	if (ret < 0)
> +		return ret;
>   
> -	return ret;
> +	ret = __phy_write(phydev, regnum, (ret & ~mask) | set);
> +
> +	return ret < 0 ? ret: 0;

    Need another space, before ':'...

>   }
>   EXPORT_SYMBOL_GPL(__phy_modify);
>   

MBR, Sergei

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ