mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7915: check return value before accessing free_block_num
Check return value of mt7915_mcu_get_eeprom_free_block() first before
accessing free_block_num.
Fixes: bbc1d4154ec1 ("mt76: mt7915: add default calibrated data support")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
+12
-7
@@ -110,18 +110,23 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
|
||||
} else {
|
||||
u8 free_block_num;
|
||||
u32 block_num, i;
|
||||
u32 eeprom_blk_size = MT7915_EEPROM_BLOCK_SIZE;
|
||||
|
||||
mt7915_mcu_get_eeprom_free_block(dev, &free_block_num);
|
||||
/* efuse info not enough */
|
||||
ret = mt7915_mcu_get_eeprom_free_block(dev, &free_block_num);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* efuse info isn't enough */
|
||||
if (free_block_num >= 29)
|
||||
return -EINVAL;
|
||||
|
||||
/* read eeprom data from efuse */
|
||||
block_num = DIV_ROUND_UP(eeprom_size,
|
||||
MT7915_EEPROM_BLOCK_SIZE);
|
||||
for (i = 0; i < block_num; i++)
|
||||
mt7915_mcu_get_eeprom(dev,
|
||||
i * MT7915_EEPROM_BLOCK_SIZE);
|
||||
block_num = DIV_ROUND_UP(eeprom_size, eeprom_blk_size);
|
||||
for (i = 0; i < block_num; i++) {
|
||||
ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return mt7915_check_eeprom(dev);
|
||||
|
||||
+6
-4
@@ -2792,8 +2792,9 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
|
||||
int ret;
|
||||
u8 *buf;
|
||||
|
||||
ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(EFUSE_ACCESS), &req,
|
||||
sizeof(req), true, &skb);
|
||||
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
|
||||
MCU_EXT_QUERY(EFUSE_ACCESS),
|
||||
&req, sizeof(req), true, &skb);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -2818,8 +2819,9 @@ int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num)
|
||||
struct sk_buff *skb;
|
||||
int ret;
|
||||
|
||||
ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(EFUSE_FREE_BLOCK), &req,
|
||||
sizeof(req), true, &skb);
|
||||
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
|
||||
MCU_EXT_QUERY(EFUSE_FREE_BLOCK),
|
||||
&req, sizeof(req), true, &skb);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user