mac80211: correct legacy rates check in ieee80211_calc_rx_airtime
[platform/kernel/linux-rpi.git] / net / mac80211 / airtime.c
index 26d2f8b..8555a0e 100644 (file)
@@ -457,6 +457,9 @@ static u32 ieee80211_get_rate_duration(struct ieee80211_hw *hw,
                         (status->encoding == RX_ENC_HE && streams > 8)))
                return 0;
 
+       if (idx >= MCS_GROUP_RATES)
+               return 0;
+
        duration = airtime_mcs_groups[group].duration[idx];
        duration <<= airtime_mcs_groups[group].shift;
        *overhead = 36 + (streams << 2);
@@ -477,7 +480,9 @@ u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
                bool sp = status->enc_flags & RX_ENC_FLAG_SHORTPRE;
                bool cck;
 
-               if (WARN_ON_ONCE(status->band > NL80211_BAND_5GHZ))
+               /* on 60GHz or sub-1GHz band, there are no legacy rates */
+               if (WARN_ON_ONCE(status->band == NL80211_BAND_60GHZ ||
+                                status->band == NL80211_BAND_S1GHZ))
                        return 0;
 
                sband = hw->wiphy->bands[status->band];