Skip to contentSkip to conversation

wifi: mt76: mt7925: check the response skb in mt7925_mcu_get_temperature()

PATCH New JB Tsai 1 participant 1 message Dec 1

Subsystems (2)
lore
Share & tools
lore

JB Tsai

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7925: check the response skb in mt7925_mcu_get_temperature()

From: Jared Huang <[email protected]>

mt76_mcu_send_and_get_msg() can return 0 without setting the response skb, as the mcu_send_msg path does not take one. A 0 return value thus does not mean that skb is valid, and mt7925_mcu_get_temperature() would read skb->len from an uninitialized pointer.

Initialize skb to NULL and return -EINVAL if no response skb is set.

---
 drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -1
index d89230fc9687..5cf09ceb9188 100644
@@ -1086,14 +1086,16 @@ int mt7925_mcu_get_temperature(struct mt792x_phy *phy)
 		__le32 temperature;
 	} __packed * evt;
 	struct mt792x_dev *dev = phy->dev;
+	struct sk_buff *skb = NULL;
 	int temperature, ret;
-	struct sk_buff *skb;
 
 	ret = mt76_mcu_send_and_get_msg(&dev->mt76,
 					MCU_WM_UNI_CMD_QUERY(THERMAL),
 					&req, sizeof(req), true, &skb);
 	if (ret)
 		return ret;
+	if (!skb)
+		return -EINVAL;
 	if (skb->len < 4 + sizeof(struct tlv) + sizeof(*evt)) {
 		dev_kfree_skb(skb);
 		return -EINVAL;
Signature · 1 line
2.45.2