Skip to contentSkip to conversation

staging: wfx: avoid uninitialized variable use

PATCH In review Arnd Bergmann 3 participants 3 messages Oct 26, 2020 – Oct 27, 2020 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wfx: avoid uninitialized variable use

From: Arnd Bergmann <[email protected]>

Move the added check of the 'band' variable after the initialization. Pointed out by clang with

drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized when used here [-Wuninitialized]

        if (rate->idx >= band->n_bitrates) {
Fixes 868fd970e187 ("staging: wfx: improve robustness of wfx_get_hw_rate()")
---
 drivers/staging/wfx/data_tx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/wfx/data_tx.c +3 -3
index 41f6a604a697..36b36ef39d05 100644
@@ -31,13 +31,13 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
 		}
 		return rate->idx + 14;
 	}
+	// WFx only support 2GHz, else band information should be retrieved
+	// from ieee80211_tx_info
+	band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
 	if (rate->idx >= band->n_bitrates) {
 		WARN(1, "wrong rate->idx value: %d", rate->idx);
 		return -1;
 	}
-	// WFx only support 2GHz, else band information should be retrieved
-	// from ieee80211_tx_info
-	band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
 	return band->bitrates[rate->idx].hw_value;
 }
 
Signature · 1 line
2.27.0
#1 lore raw
Quoted 8 lines · On Monday 26 October 2020 17:02:22 CET Arnd Bergmann wrote:

From: Arnd Bergmann <[email protected]>

Move the added check of the 'band' variable after the initialization. Pointed out by clang with

drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized when used here [-Wuninitialized]

        if (rate->idx >= band->n_bitrates) {

Hello Arnd,

This patch has already been submitted[1]. I think it is going to be applied to staging very soon.

Sorry for the disturbing.

[1] https://lore.kernel.org/driverdev-devel/[email protected]/

Signature · 1 line
Jérôme Pouiller
#2 lore raw
Quoted 10 lines · Jérôme Pouiller
Quoted 8 lines · On Monday 26 October 2020 17:02:22 CET Arnd Bergmann wrote:

From: Arnd Bergmann <[email protected]>

Move the added check of the 'band' variable after the initialization. Pointed out by clang with

drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized when used here [-Wuninitialized]

        if (rate->idx >= band->n_bitrates) {
Quoted 8 lines

Hello Arnd,

This patch has already been submitted[1]. I think it is going to be applied to staging very soon.

Sorry for the disturbing.

[1] https://lore.kernel.org/driverdev-devel/[email protected]/

Sorry for the delay, had to wait until -rc1 was out.

Now queued up in my tree.

greg k-h