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]
Message-ID: <20220519043306.GS4009@kadam>
Date:   Thu, 19 May 2022 07:33:06 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Pavel Skripkin <paskripkin@...il.com>
Cc:     gregkh@...uxfoundation.org, Larry.Finger@...inger.net,
        phil@...lpotter.co.uk, straube.linux@...il.com,
        fmdefrancesco@...il.com, linux-kernel@...r.kernel.org,
        linux-staging@...ts.linux.dev
Subject: Re: [PATCH 1/4] staging: r8188eu: add error handling of rtw_read8

On Thu, May 19, 2022 at 01:11:51AM +0300, Pavel Skripkin wrote:
> @@ -240,12 +259,14 @@ int rtl8188e_firmware_download(struct adapter *padapter)
>  {
>  	int ret = _SUCCESS;
>  	u8 write_fw_retry = 0;
> +	u8 reg;
>  	unsigned long fwdl_timeout;
>  	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
>  	struct device *device = dvobj_to_dev(dvobj);
>  	struct rt_firmware_hdr *fwhdr = NULL;
>  	u8 *fw_data;
>  	u32 fw_size;
> +	int res;
>  
>  	if (!dvobj->firmware.data)
>  		ret = load_firmware(&dvobj->firmware, device);
> @@ -269,7 +290,11 @@ int rtl8188e_firmware_download(struct adapter *padapter)
>  
>  	/*  Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */
>  	/*  or it will cause download Fw fail. 2010.02.01. by tynli. */
> -	if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */
> +	res = rtw_read8(padapter, REG_MCUFWDL, &reg);
> +	if (res)
> +		goto exit;

You didn't introduce this bug, but this path needs to have an error code
set.  Also we really need to get rid of the _FAIL garbage.  When I saw
this, I got "ret" and "res" mixed up so I thought we were returning
negative error codes instead of _FAIL.  That would   But then I saw we
are returning success.

> +
> +	if (reg & RAM_DL_SEL) { /* 8051 RAM code */
>  		rtw_write8(padapter, REG_MCUFWDL, 0x00);
>  		rtw_reset_8051(padapter);
>  	}
> @@ -278,7 +303,14 @@ int rtl8188e_firmware_download(struct adapter *padapter)
>  	fwdl_timeout = jiffies + msecs_to_jiffies(500);
>  	while (1) {
>  		/* reset the FWDL chksum */
> -		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_CHKSUM_RPT);
> +		res = rtw_read8(padapter, REG_MCUFWDL, &reg);
> +		if (res == -ENODEV)
> +			break;
> +
> +		if (res)
> +			continue;

This continue is wrong.  If res = -EPERM then it's a forever loop.
Let's just break for every error.

> +
> +		rtw_write8(padapter, REG_MCUFWDL, reg | FWDL_CHKSUM_RPT);
>  
>  		ret = write_fw(padapter, fw_data, fw_size);
>  
> diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c
> index 2f3000428af7..b532e614c5b6 100644
> --- a/drivers/staging/r8188eu/core/rtw_led.c
> +++ b/drivers/staging/r8188eu/core/rtw_led.c
> @@ -34,28 +34,38 @@ static void ResetLedStatus(struct LED_871x *pLed)
>  
>  static void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
>  {
> -	u8	LedCfg;
> +	u8 LedCfg;

Please don't make unrelated changes.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ