Skip to content

Commit

Permalink
mt76: Off by one in mt76_calc_rx_airtime()
Browse files Browse the repository at this point in the history
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: 5ce09c1 ("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>
  • Loading branch information
Dan Carpenter authored and Kalle Valo committed Dec 18, 2019
1 parent d68f4e4 commit b43e36d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/wireless/mediatek/mt76/airtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit b43e36d

Please sign in to comment.