diff mbox series

ath10k: work around uninitialized vht_pfr variable

Message ID 20190708125050.3689133-1-arnd@arndb.de
State Accepted
Commit ff414f31ce3750d259549c3b9eac8e855b5348f0
Headers show
Series ath10k: work around uninitialized vht_pfr variable | expand

Commit Message

Arnd Bergmann July 8, 2019, 12:50 p.m. UTC
As clang points out, the vht_pfr is assigned to a struct member
without being initialized in one case:

drivers/net/wireless/ath/ath10k/mac.c:7528:7: error: variable 'vht_pfr' is used uninitialized whenever 'if' condition
      is false [-Werror,-Wsometimes-uninitialized]
                if (!ath10k_mac_can_set_bitrate_mask(ar, band, mask,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath10k/mac.c:7551:20: note: uninitialized use occurs here
                arvif->vht_pfr = vht_pfr;
                                 ^~~~~~~
drivers/net/wireless/ath/ath10k/mac.c:7528:3: note: remove the 'if' if its condition is always true
                if (!ath10k_mac_can_set_bitrate_mask(ar, band, mask,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath10k/mac.c:7483:12: note: initialize the variable 'vht_pfr' to silence this warning
        u8 vht_pfr;

Add an explicit but probably incorrect initialization here.
I suspect we want a better fix here, but chose this approach to
illustrate the issue.

Fixes: 8b97b055dc9d ("ath10k: fix failure to set multiple fixed rate")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/net/wireless/ath/ath10k/mac.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.20.0

Comments

Kalle Valo July 15, 2019, 9:44 a.m. UTC | #1
Arnd Bergmann <arnd@arndb.de> writes:

> As clang points out, the vht_pfr is assigned to a struct member

> without being initialized in one case:

>

> drivers/net/wireless/ath/ath10k/mac.c:7528:7: error: variable 'vht_pfr' is used uninitialized whenever 'if' condition

>       is false [-Werror,-Wsometimes-uninitialized]

>                 if (!ath10k_mac_can_set_bitrate_mask(ar, band, mask,

>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> drivers/net/wireless/ath/ath10k/mac.c:7551:20: note: uninitialized use occurs here

>                 arvif->vht_pfr = vht_pfr;

>                                  ^~~~~~~

> drivers/net/wireless/ath/ath10k/mac.c:7528:3: note: remove the 'if' if its condition is always true

>                 if (!ath10k_mac_can_set_bitrate_mask(ar, band, mask,

>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> drivers/net/wireless/ath/ath10k/mac.c:7483:12: note: initialize the variable 'vht_pfr' to silence this warning

>         u8 vht_pfr;

>

> Add an explicit but probably incorrect initialization here.

> I suspect we want a better fix here, but chose this approach to

> illustrate the issue.

>

> Fixes: 8b97b055dc9d ("ath10k: fix failure to set multiple fixed rate")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


I'll queue this for v5.3.

-- 
Kalle Valo
Kalle Valo July 15, 2019, 5:50 p.m. UTC | #2
Arnd Bergmann <arnd@arndb.de> wrote:

> As clang points out, the vht_pfr is assigned to a struct member

> without being initialized in one case:

> 

> drivers/net/wireless/ath/ath10k/mac.c:7528:7: error: variable 'vht_pfr' is used uninitialized whenever 'if' condition

>       is false [-Werror,-Wsometimes-uninitialized]

>                 if (!ath10k_mac_can_set_bitrate_mask(ar, band, mask,

>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> drivers/net/wireless/ath/ath10k/mac.c:7551:20: note: uninitialized use occurs here

>                 arvif->vht_pfr = vht_pfr;

>                                  ^~~~~~~

> drivers/net/wireless/ath/ath10k/mac.c:7528:3: note: remove the 'if' if its condition is always true

>                 if (!ath10k_mac_can_set_bitrate_mask(ar, band, mask,

>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> drivers/net/wireless/ath/ath10k/mac.c:7483:12: note: initialize the variable 'vht_pfr' to silence this warning

>         u8 vht_pfr;

> 

> Add an explicit but probably incorrect initialization here.

> I suspect we want a better fix here, but chose this approach to

> illustrate the issue.

> 

> Fixes: 8b97b055dc9d ("ath10k: fix failure to set multiple fixed rate")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>


Patch applied to wireless-drivers.git, thanks.

ff414f31ce37 ath10k: work around uninitialized vht_pfr variable

-- 
https://patchwork.kernel.org/patch/11034993/

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

Patch

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index e43a566eef77..0606416dc971 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -7541,6 +7541,8 @@  static int ath10k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
 								&vht_nss,
 								true);
 			update_bitrate_mask = false;
+		} else {
+			vht_pfr = 0;
 		}
 
 		mutex_lock(&ar->conf_mutex);