1: 14600e747950 ! 1: 2217ace35ccf wifi: mt76: mt7996: add thermal zone device registration @@ Commit message thermal-sensors DT property references this device, which is the expected case on platforms without a thermal zone configured.  - Unregister the thermal zone together with the existing cooling - device when the phy is torn down, and on the hwmon registration - failure path in the same init routine, so neither is left registered - against a phy that is about to be freed. + Unregister the thermal zone together with the existing cooling device + when the phy is torn down, and on the hwmon registration failure path + in the same init routine, so neither is left registered against a phy + that is about to be freed. Clear both pointers after unregistering, + since this init-time failure path can now run before the normal + teardown path also unregisters the same phy, and without clearing them, + that second call would unregister already-freed objects.  Signed-off-by: Ryan Leung   @@ drivers/net/wireless/mediatek/mt76/mt7996/init.c: static const struct thermal_co struct wiphy *wiphy = phy->mt76->hw->wiphy; char name[sizeof("cooling_deviceXXX")];  -+ if (phy->tzone) ++ if (phy->tzone) {  + devm_thermal_of_zone_unregister(phy->dev->mt76.dev, phy->tzone); ++ phy->tzone = NULL; ++ }  + if (!phy->cdev) return;  + snprintf(name, sizeof(name), "cooling_device%d", phy->mt76->band_idx); + sysfs_remove_link(&wiphy->dev.kobj, name); + thermal_cooling_device_unregister(phy->cdev); ++ phy->cdev = NULL; + } +  + static int mt7996_thermal_init(struct mt7996_phy *phy)  @@ drivers/net/wireless/mediatek/mt76/mt7996/init.c: static int mt7996_thermal_init(struct mt7996_phy *phy) phy->throttle_temp[MT7996_CRIT_TEMP_IDX] = MT7996_CRIT_TEMP; phy->throttle_temp[MT7996_MAX_TEMP_IDX] = MT7996_MAX_TEMP;