linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mt76: Off by one in mt76_calc_rx_airtime()
@ 2019-11-26  4:49 Dan Carpenter
  2019-11-26  5:21 ` Kalle Valo
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Dan Carpenter @ 2019-11-26  4:49 UTC (permalink / raw)
  To: Felix Fietkau
  Cc: Ryder Lee, kernel-janitors, linux-wireless, Matthias Brugger,
	linux-mediatek, Roy Luo, Lorenzo Bianconi, Kalle Valo

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>
---
 drivers/net/wireless/mediatek/mt76/airtime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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];
-- 
2.11.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-12-18 18:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26  4:49 [PATCH] mt76: Off by one in mt76_calc_rx_airtime() Dan Carpenter
2019-11-26  5:21 ` Kalle Valo
2019-11-26  5:25 ` Markus Theil
2019-11-26  8:04 ` Toke Høiland-Jørgensen
2019-11-26  9:11   ` Dan Carpenter
2019-11-26  9:16     ` Toke Høiland-Jørgensen
2019-11-26  9:23       ` Kalle Valo
2019-11-26 12:09   ` [PATCH] mac80211: airtime: Fix an off by one in ieee80211_calc_rx_airtime() Dan Carpenter
2019-11-26 12:39     ` Toke Høiland-Jørgensen
2019-12-18 18:51 ` [PATCH] mt76: Off by one in mt76_calc_rx_airtime() Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).