Skip to contentSkip to conversation

staging: r8188eu: Fix smatch warnings in os_dep/*.c

bug report Dan Carpenter 2 participants 2 messages Sep 17, 2021 Staging

lore
Share & tools
lore
#0 lore raw

Hello Larry and Martin,

The patch 0d5e4bfe47ea: "staging: r8188eu: Fix smatch warnings in os_dep/*.c" from Aug 11, 2021, leads to the following Smatch static checker warning:

	drivers/staging/r8188eu/os_dep/usb_intf.c:286 rtw_hw_resume()
	warn: variable dereferenced before check 'padapter' (see line 284)

drivers/staging/r8188eu/os_dep/usb_intf.c

    281 int rtw_hw_resume(struct adapter *padapter)
    282 {
    283         struct pwrctrl_priv *pwrpriv;
    284         struct net_device *pnetdev = padapter->pnetdev;
                                             ^^^^^^^^^^^^^^^^^

Dereferenced

    285 
--> 286         if (!padapter)
                    ^^^^^^^^^

Checked too late.

This warning was silenced when Smatch could tell that "padapter" was non-NULL but Martin removed the last caller in commit c0a099b7341c ("staging: r8188eu: bHWPwrPindetect is always false").

So the correct fix is to just delete this function?

    287                 goto error_exit;
    288         pwrpriv = &padapter->pwrctrlpriv;
    289         DBG_88E("==> rtw_hw_resume\n");
    290         _enter_pwrlock(&pwrpriv->lock);
    291         pwrpriv->bips_processing = true;
    292         rtw_reset_drv_sw(padapter);
    293 

regards,
dan carpenter

#1 lore raw

Hello Dan,

Thus wrote Dan Carpenter ([email protected]):

Quoted 21 lines

Hello Larry and Martin,

The patch 0d5e4bfe47ea: "staging: r8188eu: Fix smatch warnings in os_dep/*.c" from Aug 11, 2021, leads to the following Smatch static checker warning:

	drivers/staging/r8188eu/os_dep/usb_intf.c:286 rtw_hw_resume()
	warn: variable dereferenced before check 'padapter' (see line 284)

drivers/staging/r8188eu/os_dep/usb_intf.c

    281 int rtw_hw_resume(struct adapter *padapter)
    282 {
    283         struct pwrctrl_priv *pwrpriv;
    284         struct net_device *pnetdev = padapter->pnetdev;
                                             ^^^^^^^^^^^^^^^^^

Dereferenced

    285 
--> 286         if (!padapter)
                    ^^^^^^^^^
Quoted 7 lines

Checked too late.

This warning was silenced when Smatch could tell that "padapter" was non-NULL but Martin removed the last caller in commit c0a099b7341c ("staging: r8188eu: bHWPwrPindetect is always false").

So the correct fix is to just delete this function?

yes, rtw_hw_resume is no longer used. I submitted a patch to remove the function. I'll have to rebase and resend it.

Best regards,
Martin