Commit 0bb4e918 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau
Browse files

mt76: mt7615: fix hwmon temp sensor mem use-after-free



Without this change, garbage is seen in the hwmon name and sensors output
for mt7615 is garbled.

Fixes: 109e505a ("mt76: mt7615: add thermal sensor device support")
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 0ae3ff56
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -49,12 +49,14 @@ int mt7615_thermal_init(struct mt7615_dev *dev)
{
	struct wiphy *wiphy = mt76_hw(dev)->wiphy;
	struct device *hwmon;
	const char *name;

	if (!IS_REACHABLE(CONFIG_HWMON))
		return 0;

	hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev,
						       wiphy_name(wiphy), dev,
	name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7615_%s",
			      wiphy_name(wiphy));
	hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, dev,
						       mt7615_hwmon_groups);
	if (IS_ERR(hwmon))
		return PTR_ERR(hwmon);