mt76: fix possible out-of-bound access in mt7615_fill_txs/mt7603_fill_txs
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 6 Nov 2019 23:01:58 +0000 (01:01 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 20 Nov 2019 12:23:51 +0000 (13:23 +0100)
Fix possible out-of-bound access of status rates array in
mt7615_fill_txs/mt7603_fill_txs routines

Fixes: c5211e997eca ("mt76: mt7603: rework and fix tx status reporting")
Fixes: 4af81f02b49c ("mt76: mt7615: sync with mt7603 rate control changes")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7603/mac.c
drivers/net/wireless/mediatek/mt76/mt7615/mac.c

index 1497d5e..812d081 100644 (file)
@@ -1136,8 +1136,10 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta,
                if (idx && (cur_rate->idx != info->status.rates[i].idx ||
                            cur_rate->flags != info->status.rates[i].flags)) {
                        i++;
-                       if (i == ARRAY_SIZE(info->status.rates))
+                       if (i == ARRAY_SIZE(info->status.rates)) {
+                               i--;
                                break;
+                       }
 
                        info->status.rates[i] = *cur_rate;
                        info->status.rates[i].count = 0;
index 2b810ba..c77adc5 100644 (file)
@@ -1039,8 +1039,10 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,
                if (idx && (cur_rate->idx != info->status.rates[i].idx ||
                            cur_rate->flags != info->status.rates[i].flags)) {
                        i++;
-                       if (i == ARRAY_SIZE(info->status.rates))
+                       if (i == ARRAY_SIZE(info->status.rates)) {
+                               i--;
                                break;
+                       }
 
                        info->status.rates[i] = *cur_rate;
                        info->status.rates[i].count = 0;