mt76: add a bound check in mt76_calculate_default_rate()

basic_rate could be 0 ie. hidden AP. Always pick the lowest rate
for such cases.

Fixes: 75fb2e62d444 (mt76: add mt76_default_basic_rate more devices can rely on)
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Ryder Lee
2021-09-24 17:27:25 +02:00
committed by Felix Fietkau
parent 9848094e4b
commit 5710d06434
+4
View File
@@ -1356,6 +1356,10 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)
if (phy->chandef.chan->band == NL80211_BAND_5GHZ)
offset = 4;
/* pick the lowest rate for hidden nodes */
if (rateidx < 0)
rateidx = 0;
rate = &mt76_rates[offset + rateidx];
return rate->hw_value;