netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
@ 2022-10-20 13:57 Colin Ian King
  2022-10-20 15:11 ` Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Colin Ian King @ 2022-10-20 13:57 UTC (permalink / raw)
  To: Jes Sorensen, Kalle Valo, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Bitterblue Smith, linux-wireless,
	netdev
  Cc: kernel-janitors, linux-kernel

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) {
                ^~~~~~~~~~~~~

Fixes: c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index 99610bb2afd5..0025bb32538d 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -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);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
  2022-10-20 13:57 [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1 Colin Ian King
@ 2022-10-20 15:11 ` Nathan Chancellor
  2022-10-21  5:09 ` Kalle Valo
  2022-10-21 12:55 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2022-10-20 15:11 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Jes Sorensen, Kalle Valo, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Bitterblue Smith, linux-wireless,
	netdev, kernel-janitors, linux-kernel

On Thu, Oct 20, 2022 at 02:57:09PM +0100, Colin Ian King wrote:
> 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) {
>                 ^~~~~~~~~~~~~
> 
> Fixes: c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

I was getting ready to send a similar patch.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> index 99610bb2afd5..0025bb32538d 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> @@ -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);
> -- 
> 2.37.3
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
  2022-10-20 13:57 [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1 Colin Ian King
  2022-10-20 15:11 ` Nathan Chancellor
@ 2022-10-21  5:09 ` Kalle Valo
  2022-10-21 10:48   ` Kalle Valo
  2022-10-21 12:55 ` Kalle Valo
  2 siblings, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2022-10-21  5:09 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Jes Sorensen, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bitterblue Smith, linux-wireless, netdev,
	kernel-janitors, linux-kernel

Colin Ian King <colin.i.king@gmail.com> writes:

> 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) {
>                 ^~~~~~~~~~~~~
>
> Fixes: c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

I'll queue this to v6.1.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
  2022-10-21  5:09 ` Kalle Valo
@ 2022-10-21 10:48   ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2022-10-21 10:48 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Jes Sorensen, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bitterblue Smith, linux-wireless, netdev,
	kernel-janitors, linux-kernel

Kalle Valo <kvalo@kernel.org> writes:

> Colin Ian King <colin.i.king@gmail.com> writes:
>
>> 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) {
>>                 ^~~~~~~~~~~~~
>>
>> Fixes: c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>
> 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.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1
  2022-10-20 13:57 [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1 Colin Ian King
  2022-10-20 15:11 ` Nathan Chancellor
  2022-10-21  5:09 ` Kalle Valo
@ 2022-10-21 12:55 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2022-10-21 12:55 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Jes Sorensen, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bitterblue Smith, linux-wireless, netdev,
	kernel-janitors, linux-kernel

Colin Ian King <colin.i.king@gmail.com> wrote:

> 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) {
>                 ^~~~~~~~~~~~~
> 
> Fixes: c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>

Patch applied to wireless-next.git, thanks.

80e5acb6dd72 wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20221020135709.1549086-1-colin.i.king@gmail.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-21 12:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-20 13:57 [PATCH][next] wifi: rtl8xxxu: Fix reads of uninitialized variables hw_ctrl_s1, sw_ctrl_s1 Colin Ian King
2022-10-20 15:11 ` Nathan Chancellor
2022-10-21  5:09 ` Kalle Valo
2022-10-21 10:48   ` Kalle Valo
2022-10-21 12:55 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).