diff --git a/mt76x02_mac.c b/mt76x02_mac.c index 21f8b1e6..231685bb 100644 --- a/mt76x02_mac.c +++ b/mt76x02_mac.c @@ -302,10 +302,14 @@ mt76x02_mac_process_tx_rate(struct ieee80211_tx_rate *txrate, u16 rate, txrate->flags |= IEEE80211_TX_RC_GREEN_FIELD; fallthrough; case MT_PHY_TYPE_HT: + if (idx > 31) + return -EINVAL; txrate->flags |= IEEE80211_TX_RC_MCS; txrate->idx = idx; break; case MT_PHY_TYPE_VHT: + if ((idx & 0xf) > 9) + return -EINVAL; txrate->flags |= IEEE80211_TX_RC_VHT_MCS; txrate->idx = idx; break; @@ -493,18 +497,21 @@ mt76x02_mac_fill_tx_status(struct mt76x02_dev *dev, struct mt76x02_sta *msta, first_rate = st->rate & ~MT_PKTID_RATE; first_rate |= st->pktid & MT_PKTID_RATE; - mt76x02_mac_process_tx_rate(&rate[0], first_rate, - dev->mphy.chandef.chan->band); + if (mt76x02_mac_process_tx_rate(&rate[0], first_rate, + dev->mphy.chandef.chan->band)) + return; } else if (rate[0].idx < 0) { if (!msta) return; - mt76x02_mac_process_tx_rate(&rate[0], msta->wcid.tx_info, - dev->mphy.chandef.chan->band); + if (mt76x02_mac_process_tx_rate(&rate[0], msta->wcid.tx_info, + dev->mphy.chandef.chan->band)) + return; } - mt76x02_mac_process_tx_rate(&last_rate, st->rate, - dev->mphy.chandef.chan->band); + if (mt76x02_mac_process_tx_rate(&last_rate, st->rate, + dev->mphy.chandef.chan->band)) + return; for (i = 0; i < ARRAY_SIZE(info->status.rates); i++) { retry--;