]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:37:17 +0000 (18:37 +0200)
[ Upstream commit 03ee8f73801a8f46d83dfc2bf73fb9ffa5a21602 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7925/init.c

index 14553dcc61c5771485c7abf238d70fbd9970248b..02899320da5c1b80369621aa9f70e38bcd8d3b99 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);