wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
PATCH 1/1 wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
Variables hw_ctrl_s1 and sw_ctrl_s1 are not being initialized and potentially can contain any garbage value. Currently there is an if statement that sets one or the other of these variables, followed by an if statement that checks if any of these variables have been set to a non-zero value. In the case where they may contain uninitialized non-zero values, the latter if statement may be taken as true when it was not expected to.
Fix this by ensuring hw_ctrl_s1 and sw_ctrl_s1 are initialized.
Cleans up clang warning:drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:7: warning:
variable 'hw_ctrl_s1' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (hw_ctrl) {
^~~~~~~
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:440:7: note: uninitialized
use occurs here
if (hw_ctrl_s1 || sw_ctrl_s1) {
^~~~~~~~~~
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:3: note: remove the 'if'
if its condition is always true
if (hw_ctrl) {
^~~~~~~~~~~~~--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +1 -1
@@ -412,7 +412,7 @@ static void rtl8188f_spur_calibration(struct rtl8xxxu_priv *priv, u8 channel) };const u8 threshold =0x16 ; -bool do_notch, hw_ctrl, sw_ctrl, hw_ctrl_s1, sw_ctrl_s1; +bool do_notch, hw_ctrl, sw_ctrl, hw_ctrl_s1 =0 , sw_ctrl_s1 =0 ;u32 val32, initial_gain, reg948; val32 =rtl8xxxu_read32 (priv,REG_OFDM0_RX_D_SYNC_PATH );
Signature · 1 line
2.37.3
Quoted 25 lines · Colin Ian King
Variables
hw_ctrl_s1andsw_ctrl_s1are not being initialized and potentially can contain any garbage value. Currently there is an if statement that sets one or the other of these variables, followed by an if statement that checks if any of these variables have been set to a non-zero value. In the case where they may contain uninitialized non-zero values, the latter if statement may be taken as true when it was not expected to.Fix this by ensuring
hw_ctrl_s1andsw_ctrl_s1are initialized.Cleans up clang warning:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:7: warning:
variable 'hw_ctrl_s1' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (hw_ctrl) { ^~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:440:7: note: uninitialized use occurs here if (hw_ctrl_s1 || sw_ctrl_s1) { ^~~~~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:3: note: remove the 'if' if its condition is always true if (hw_ctrl) { ^~~~~~~~~~~~~
Quoted 2 lines
Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")Signed-off-by Colin Ian King <[email protected]>
I was getting ready to send a similar patch.
Quoted 21 lines
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +1
-1@@ -412,7 +412,7 @@ static void rtl8188f_spur_calibration(struct rtl8xxxu_priv *priv, u8 channel) };const u8 threshold =0x16 ; -bool do_notch, hw_ctrl, sw_ctrl, hw_ctrl_s1, sw_ctrl_s1; +bool do_notch, hw_ctrl, sw_ctrl, hw_ctrl_s1 =0 , sw_ctrl_s1 =0 ;u32 val32, initial_gain, reg948; val32 =rtl8xxxu_read32 (priv,REG_OFDM0_RX_D_SYNC_PATH );Signature · 1 line
2.37.3
Quoted 25 lines · Colin Ian King
Variables
hw_ctrl_s1andsw_ctrl_s1are not being initialized and potentially can contain any garbage value. Currently there is an if statement that sets one or the other of these variables, followed by an if statement that checks if any of these variables have been set to a non-zero value. In the case where they may contain uninitialized non-zero values, the latter if statement may be taken as true when it was not expected to.Fix this by ensuring
hw_ctrl_s1andsw_ctrl_s1are initialized.Cleans up clang warning:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:7: warning:
variable 'hw_ctrl_s1' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (hw_ctrl) { ^~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:440:7: note: uninitialized use occurs here if (hw_ctrl_s1 || sw_ctrl_s1) { ^~~~~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:3: note: remove the 'if' if its condition is always true if (hw_ctrl) { ^~~~~~~~~~~~~
Quoted 2 lines
Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")Signed-off-by Colin Ian King <[email protected]>
I'll queue this to v6.1.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 27 lines · Kalle Valo
Quoted 25 lines · Colin Ian King
Variables
hw_ctrl_s1andsw_ctrl_s1are not being initialized and potentially can contain any garbage value. Currently there is an if statement that sets one or the other of these variables, followed by an if statement that checks if any of these variables have been set to a non-zero value. In the case where they may contain uninitialized non-zero values, the latter if statement may be taken as true when it was not expected to.Fix this by ensuring
hw_ctrl_s1andsw_ctrl_s1are initialized.Cleans up clang warning:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:7: warning:
variable 'hw_ctrl_s1' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (hw_ctrl) { ^~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:440:7: note: uninitialized use occurs here if (hw_ctrl_s1 || sw_ctrl_s1) { ^~~~~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:3: note: remove the 'if' if its condition is always true if (hw_ctrl) { ^~~~~~~~~~~~~
Quoted 4 lines
Quoted 2 lines
Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")Signed-off-by Colin Ian King <[email protected]>I'll queue this to v6.1.
Actually commit c888183b21f3 is in wireless-next so this patch should go to wireless-next, for v6.2.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 25 lines · Colin Ian King
Variables
hw_ctrl_s1andsw_ctrl_s1are not being initialized and potentially can contain any garbage value. Currently there is an if statement that sets one or the other of these variables, followed by an if statement that checks if any of these variables have been set to a non-zero value. In the case where they may contain uninitialized non-zero values, the latter if statement may be taken as true when it was not expected to.Fix this by ensuring
hw_ctrl_s1andsw_ctrl_s1are initialized.Cleans up clang warning:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:7: warning:
variable 'hw_ctrl_s1' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (hw_ctrl) { ^~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:440:7: note: uninitialized use occurs here if (hw_ctrl_s1 || sw_ctrl_s1) { ^~~~~~~~~~ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c:432:3: note: remove the 'if' if its condition is always true if (hw_ctrl) { ^~~~~~~~~~~~~
Quoted 3 lines
Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")Signed-off-by Colin Ian King <[email protected]>Reviewed-by Nathan Chancellor <[email protected]>
Patch applied to wireless-next.git, thanks.
80e5acb6dd72 wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches