Skip to content

Commit 87f600a

Browse files
PhilPottergregkh
authored andcommitted
staging: r8188eu: fix potential uninitialised variable use in rtw_pwrctrl.c
Set ret to 0 (success) before entering first if statement, thereby assuring that even if the device is not associated and further checks pass, we do not then end up returning the uninitialized value of ret. This assignment is deliberately now directly before the if statement, in order to keep it clear what is happening as opposed to having it as an initialization at the start of the function like it was originally. Also add a comment to make it clear this first if block is currently a success path. As a side note, smatch does not trigger warnings for this change, for me at least. Within core/rtw_pwrctrl.c in the rtw_pwr_wakeup function, I previously dropped the initialization of 'ret' (int ret = 0;) in favour of its assignment which happens inside the first if block directly before its corresponding goto. This was the cause of this bug, and was introduced by: commit f3a7601 ("staging: r8188eu: remove initializer from ret in rtw_pwr_wakeup"). Fixes: f3a7601 ("staging: r8188eu: remove initializer from ret in rtw_pwr_wakeup") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Phillip Potter <phil@philpotter.co.uk> Link: https://lore.kernel.org/r/20220730235910.1145-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f3a7601 commit 87f600a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/staging/r8188eu/core/rtw_pwrctrl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ int rtw_pwr_wakeup(struct adapter *padapter)
387387
msleep(10);
388388

389389
/* I think this should be check in IPS, LPS, autosuspend functions... */
390-
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
391-
ret = 0;
390+
/* Below goto is a success path taken for already linked devices */
391+
ret = 0;
392+
if (check_fwstate(pmlmepriv, _FW_LINKED))
392393
goto exit;
393-
}
394394

395395
if (pwrpriv->rf_pwrstate == rf_off && ips_leave(padapter) == _FAIL) {
396396
ret = -ENOMEM;

0 commit comments

Comments
 (0)