[PATCH] mt76: add a bound check in mt76_calculate_default_rate()

Ryder Lee ryder.lee at mediatek.com
Tue Aug 17 08:11:19 PDT 2021


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 <ryder.lee at mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index e282c627e25c..3658328f513b 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1360,6 +1360,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;
-- 
2.29.2


More information about the Linux-mediatek mailing list