wifi: mt76: mt7925: Fix null-ptr-deref in mt7925_thermal_init()
authorHenry Martin <bsdhenrymartin@gmail.com>
Wed, 25 Jun 2025 12:49:01 +0000 (20:49 +0800)
committerFelix Fietkau <nbd@nbd.name>
Mon, 7 Jul 2025 16:05:52 +0000 (18:05 +0200)
devm_kasprintf() returns NULL on error. Currently, mt7925_thermal_init()
does not check for this case, which results in a NULL pointer
dereference.

Add NULL check after devm_kasprintf() to prevent this issue.

Fixes: 396e41a74a88 ("wifi: mt76: mt7925: support temperature sensor")
Signed-off-by: Henry Martin <bsdhenryma@tencent.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patch.msgid.link/20250625124901.1839832-1-bsdhenryma@tencent.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/init.c

index 2a83ff59a968c9fab16f4d2aa82fe9dad79228ae..4249bad83c930e7eeb4e0ac97c49e34595235669 100644 (file)
@@ -52,6 +52,8 @@ static int mt7925_thermal_init(struct mt792x_phy *phy)
 
        name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7925_%s",
                              wiphy_name(wiphy));
+       if (!name)
+               return -ENOMEM;
 
        hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, phy,
                                                       mt7925_hwmon_groups);