Message ID | 20250331103543.9154-1-bsdhenrymartin@gmail.com |
---|---|
State | New |
Headers | show |
Series | wifi: mt76: mt7996: Add NULL check in mt7996_thermal_init | expand |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c index 6b660424aedc..702447022f0e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c @@ -217,6 +217,8 @@ 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);
When devm_kasprintf() fails, it returns a NULL pointer. However, this return value is not properly checked in the function mt7996_thermal_init. A NULL check should be added after the devm_kasprintf() to prevent potential NULL pointer dereference error. Fixes: 69d54ce7491d0 ("switch to single multi-radio wiphy") Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> --- drivers/net/wireless/mediatek/mt76/mt7996/init.c | 2 ++ 1 file changed, 2 insertions(+)