linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: wfx: fix use of uninitialized pointer
@ 2020-10-19 16:06 Jerome Pouiller
  2020-10-19 16:06 ` [PATCH 2/2] staging: wfx: fix test on return value of gpiod_get_value() Jerome Pouiller
  2020-10-20  1:07 ` [PATCH 1/2] staging: wfx: fix use of uninitialized pointer Nathan Chancellor
  0 siblings, 2 replies; 3+ messages in thread
From: Jerome Pouiller @ 2020-10-19 16:06 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller, kernel test robot,
	Nathan Chancellor

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

With -Wuninitialized, the compiler complains:

drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized when used here [-Wuninitialized]
    if (rate->idx >= band->n_bitrates) {
                         ^~~~

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Fixes: 868fd970e187 ("staging: wfx: improve robustness of wfx_get_hw_rate()")
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/data_tx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index 41f6a604a697..36b36ef39d05 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -31,13 +31,13 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
 		}
 		return rate->idx + 14;
 	}
-	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];
+	if (rate->idx >= band->n_bitrates) {
+		WARN(1, "wrong rate->idx value: %d", rate->idx);
+		return -1;
+	}
 	return band->bitrates[rate->idx].hw_value;
 }
 
-- 
2.28.0


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

end of thread, other threads:[~2020-10-20  1:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 16:06 [PATCH 1/2] staging: wfx: fix use of uninitialized pointer Jerome Pouiller
2020-10-19 16:06 ` [PATCH 2/2] staging: wfx: fix test on return value of gpiod_get_value() Jerome Pouiller
2020-10-20  1:07 ` [PATCH 1/2] staging: wfx: fix use of uninitialized pointer Nathan Chancellor

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).