]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mt76: mt7996: Add NULL check in mt7996_thermal_init
authorCharles Han <hanchunchao@inspur.com>
Mon, 7 Apr 2025 09:55:51 +0000 (17:55 +0800)
committerFelix Fietkau <nbd@nbd.name>
Wed, 21 May 2025 12:49:38 +0000 (14:49 +0200)
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in mt7996_thermal_init() is not checked.
Add NULL check in mt7996_thermal_init(), to handle kernel NULL
pointer dereference error.

Fixes: 69d54ce7491d ("wifi: mt76: mt7996: switch to single multi-radio wiphy")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Link: https://patch.msgid.link/20250407095551.32127-1-hanchunchao@inspur.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/init.c

index e26451add9a3da4d5e9c08e70b75d6483ad03b76..ff835a6f77ce9586c8b40bc3cc16ef07ec7799da 100644 (file)
@@ -217,6 +217,9 @@ static int mt7996_thermal_init(struct mt7996_phy *phy)
 
        name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7996_%s.%d",
                              wiphy_name(wiphy), phy->mt76->band_idx);
+       if (!name)
+               return -ENOMEM;
+
        snprintf(cname, sizeof(cname), "cooling_device%d", phy->mt76->band_idx);
 
        cdev = thermal_cooling_device_register(name, phy, &mt7996_thermal_ops);