diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-11-26 07:49:56 +0300 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2019-12-18 20:50:40 +0200 |
commit | b43e36d75e8727f78892652a25967a1ffa03d1d1 (patch) | |
tree | fa6b500d5af2002b8b61417cd20fb4fc31ccf9e9 /drivers/net/wireless | |
parent | d68f4e43a46ff1f772ff73085f96d44eb4163e9d (diff) | |
download | linux-b43e36d75e8727f78892652a25967a1ffa03d1d1.tar.gz linux-b43e36d75e8727f78892652a25967a1ffa03d1d1.tar.bz2 linux-b43e36d75e8727f78892652a25967a1ffa03d1d1.zip |
mt76: Off by one in mt76_calc_rx_airtime()
The sband->bitrates[] array has "sband->n_bitrates" elements so this
check needs to be >= instead of > or we could read beyond the end of the
array.
These values come from when we call mt76_register_device():
ret = mt76_register_device(&dev->mt76, true, mt7603_rates,
ARRAY_SIZE(mt7603_rates));
Here sband->bitrates[] is mt7603_rates[] and ->n_bitrates is the
ARRAY_SIZE()
Fixes: 5ce09c1a7907 ("mt76: track rx airtime for airtime fairness and survey")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/airtime.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/airtime.c b/drivers/net/wireless/mediatek/mt76/airtime.c index 55116f395f9a..a4a785467748 100644 --- a/drivers/net/wireless/mediatek/mt76/airtime.c +++ b/drivers/net/wireless/mediatek/mt76/airtime.c @@ -242,7 +242,7 @@ u32 mt76_calc_rx_airtime(struct mt76_dev *dev, struct mt76_rx_status *status, return 0; sband = dev->hw->wiphy->bands[status->band]; - if (!sband || status->rate_idx > sband->n_bitrates) + if (!sband || status->rate_idx >= sband->n_bitrates) return 0; rate = &sband->bitrates[status->rate_idx]; |