]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
staging: wfx: fix use of uninitialized pointer
authorJérôme Pouiller <jerome.pouiller@silabs.com>
Mon, 19 Oct 2020 16:06:03 +0000 (18:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Oct 2020 12:23:42 +0000 (13:23 +0100)
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>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Link: https://lore.kernel.org/r/20201019160604.1609180-1-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wfx/data_tx.c

index 41f6a604a697a3966a9558886548400f157f4bd3..36b36ef39d053ce88b60d5a729380224556f3273 100644 (file)
@@ -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;
 }