mt76: mt7915: fix potential overflow of eeprom page index [update]

If total eeprom size is divisible by per-page size, the i in for loop
will exceed max page index, which happens in our newer chipset.

Fixes: 26f18380e6ca ("mt76: mt7915: add support for flash mode")
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Shayne Chen
2021-08-13 12:26:46 +02:00
committed by Felix Fietkau
parent affea639c5
commit ac00fed412
+1 -1
View File
@@ -3258,7 +3258,7 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)
struct sk_buff *skb;
int ret;
if (i == total - 1 && MT7915_EEPROM_SIZE % PER_PAGE_SIZE)
if (i == total - 1 && !!(MT7915_EEPROM_SIZE % PER_PAGE_SIZE))
eep_len = MT7915_EEPROM_SIZE % PER_PAGE_SIZE;
else
eep_len = PER_PAGE_SIZE;