From 5710d0643418bb6d1aa4b49095b6ac2a25d7a0e1 Mon Sep 17 00:00:00 2001 From: Ryder Lee Date: Tue, 17 Aug 2021 23:11:19 +0800 Subject: [PATCH] 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 Signed-off-by: Felix Fietkau --- mac80211.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mac80211.c b/mac80211.c index 2a434a97..a8695d3d 100644 --- a/mac80211.c +++ b/mac80211.c @@ -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;