From ac00fed412d4adeb7e79105ccf405e0c2203bfdd Mon Sep 17 00:00:00 2001 From: Shayne Chen Date: Tue, 20 Jul 2021 10:48:32 +0800 Subject: [PATCH] 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 Signed-off-by: Shayne Chen Signed-off-by: Felix Fietkau --- mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mt7915/mcu.c b/mt7915/mcu.c index 839fc3d4..9fe2fda4 100644 --- a/mt7915/mcu.c +++ b/mt7915/mcu.c @@ -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;