]> git.baikalelectronics.ru Git - kernel.git/commit
staging: r8188eu: fix potential uninitialised variable use in rtw_pwrctrl.c
authorPhillip Potter <phil@philpotter.co.uk>
Sat, 30 Jul 2022 23:59:10 +0000 (00:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 Jul 2022 08:07:45 +0000 (10:07 +0200)
commitfa36cd901e57ddf4a5287984b125549476ed5eb8
tree072f092ca0de3dbb93b34846c58ac8daaab2c2bc
parent534186ab4f0ee9ddb99f96c845f4510e6b2932b1
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 534186ab4f0e ("staging: r8188eu: remove initializer from ret
in rtw_pwr_wakeup").

Fixes: 534186ab4f0e ("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>
drivers/staging/r8188eu/core/rtw_pwrctrl.c