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:   Sun, 9 Jan 2022 16:43:33 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     trix@...hat.com
Cc:     nbd@....name, john@...ozen.org, sean.wang@...iatek.com,
        Mark-MC.Lee@...iatek.com, davem@...emloft.net,
        matthias.bgg@...il.com, linux@...linux.org.uk, nathan@...nel.org,
        ndesaulniers@...gle.com, opensource@...rst.com,
        netdev@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
        llvm@...ts.linux.dev
Subject: Re: [PATCH] net: ethernet: mtk_eth_soc: fix error checking in
 mtk_mac_config()

On Sat,  8 Jan 2022 07:50:03 -0800 trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
> 
> Clang static analysis reports this problem
> mtk_eth_soc.c:394:7: warning: Branch condition evaluates
>   to a garbage value
>                 if (err)
>                     ^~~
> 
> err is not initialized and only conditionally set.
> Check err consistently with the rest of mtk_mac_config(),
> after even possible setting.
> 
> Fixes: 7e538372694b ("net: ethernet: mediatek: Re-add support SGMII")
> Signed-off-by: Tom Rix <trix@...hat.com>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index b67b4323cff08..a27e548488584 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -385,14 +385,16 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
>  		       0 : mac->id;
>  
>  		/* Setup SGMIISYS with the determined property */
> -		if (state->interface != PHY_INTERFACE_MODE_SGMII)
> +		if (state->interface != PHY_INTERFACE_MODE_SGMII) {
>  			err = mtk_sgmii_setup_mode_force(eth->sgmii, sid,
>  							 state);
> -		else if (phylink_autoneg_inband(mode))
> +			if (err)
> +				goto init_err;
> +		} else if (phylink_autoneg_inband(mode)) {
>  			err = mtk_sgmii_setup_mode_an(eth->sgmii, sid);
> -
> -		if (err)
> -			goto init_err;
> +			if (err)
> +				goto init_err;
> +		}
>  
>  		regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0,
>  				   SYSCFG0_SGMII_MASK, val);

Why not init err to 0 before the if or add an else err = 0; branch?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ