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: <20211208164042.6fbcddb1@thinkpad>
Date:   Wed, 8 Dec 2021 16:40:42 +0100
From:   Marek BehĂșn <kabel@...nel.org>
To:     Ameer Hamza <amhamza.mgc@...il.com>
Cc:     kuba@...nel.org, andrew@...n.ch, vivien.didelot@...il.com,
        f.fainelli@...il.com, olteanv@...il.com, davem@...emloft.net,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] net: dsa: mv88e6xxx: error handling for serdes_power
 functions

On Wed,  8 Dec 2021 19:04:13 +0500
Ameer Hamza <amhamza.mgc@...il.com> wrote:

> mv88e6390_serdes_power() and mv88e6393x_serdes_power() should return
> with EINVAL error if cmode is undefined.
> 
> Signed-off-by: Ameer Hamza <amhamza.mgc@...il.com>
> ---
>  drivers/net/dsa/mv88e6xxx/serdes.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
> index 33727439724a..f3dc1865f291 100644
> --- a/drivers/net/dsa/mv88e6xxx/serdes.c
> +++ b/drivers/net/dsa/mv88e6xxx/serdes.c
> @@ -830,7 +830,7 @@ int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
>  			   bool up)
>  {
>  	u8 cmode = chip->ports[port].cmode;
> -	int err = 0;
> +	int err;
>  
>  	switch (cmode) {
>  	case MV88E6XXX_PORT_STS_CMODE_SGMII:
> @@ -842,6 +842,8 @@ int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
>  	case MV88E6XXX_PORT_STS_CMODE_RXAUI:
>  		err = mv88e6390_serdes_power_10g(chip, lane, up);
>  		break;
> +	default:
> +		return -EINVAL;
>  	}
>  
>  	if (!err && up)
> @@ -1507,7 +1509,7 @@ int mv88e6393x_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
>  			    bool on)
>  {
>  	u8 cmode = chip->ports[port].cmode;
> -	int err = 0;
> +	int err;
>  
>  	if (port != 0 && port != 9 && port != 10)
>  		return -EOPNOTSUPP;
> @@ -1541,6 +1543,8 @@ int mv88e6393x_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
>  	case MV88E6393X_PORT_STS_CMODE_10GBASER:
>  		err = mv88e6390_serdes_power_10g(chip, lane, on);
>  		break;
> +	default:
> +		return -EINVAL;
>  	}
>  
>  	if (err)

please make it err = -EINVAL instead of direct return, so that we can
check in the code after and handle the error case.

Marek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ