[PATCH 02/11] wifi: mt76: mt7921: validate EEPROM response length

Jiale Yao yaojiale02 at 163.com
Mon Oct 19 19:45:34 PDT 2026


The EEPROM reader indexes the data array in a firmware response without
checking that the complete response structure is present. A truncated
response can therefore cause an out-of-bounds read.

Require the complete EEPROM response before indexing its data.

Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: Jiale Yao <yaojiale02 at 163.com>
---
 drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 782c8baaf776..ef6660653723 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -104,6 +104,10 @@ static int mt7921_mcu_read_eeprom(struct mt792x_dev *dev, u32 offset, u8 *val)
 					&req, sizeof(req), true, &skb);
 	if (ret)
 		return ret;
+	if (skb->len < sizeof(*res)) {
+		dev_kfree_skb(skb);
+		return -EINVAL;
+	}
 
 	res = (struct mt7921_mcu_eeprom_info *)skb->data;
 	*val = res->data[offset % MT7921_EEPROM_BLOCK_SIZE];
-- 
2.34.1




More information about the Linux-mediatek mailing list