Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

thermal: core: Free thermal zone ID later during removal

The thermal zone removal ordering is different from the thermal zone
registration rollback path ordering and the former is arguably
problematic because freeing a thermal zone ID prematurely may cause
it to be used during the registration of another thermal zone which
may fail as a result.

Prevent that from occurring by changing the thermal zone removal
ordering to reflect the thermal zone registration rollback path
ordering.

Also more the ida_destroy() call from thermal_zone_device_unregister()
to thermal_release() for consistency.

Fixes: b31ef8285b19 ("thermal core: convert ID allocation to IDA")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5063934.GXAFRqVoOG@rafael.j.wysocki

+4 -2
+4 -2
drivers/thermal/thermal_core.c
··· 965 965 tz = to_thermal_zone(dev); 966 966 thermal_zone_destroy_device_groups(tz); 967 967 thermal_set_governor(tz, NULL); 968 + ida_destroy(&tz->ida); 968 969 mutex_destroy(&tz->lock); 969 970 complete(&tz->removal); 970 971 } else if (!strncmp(dev_name(dev), "cooling_device", ··· 1730 1729 1731 1730 thermal_thresholds_exit(tz); 1732 1731 thermal_remove_hwmon_sysfs(tz); 1733 - ida_free(&thermal_tz_ida, tz->id); 1734 - ida_destroy(&tz->ida); 1735 1732 1736 1733 device_del(&tz->device); 1737 1734 put_device(&tz->device); ··· 1737 1738 thermal_notify_tz_delete(tz); 1738 1739 1739 1740 wait_for_completion(&tz->removal); 1741 + 1742 + ida_free(&thermal_tz_ida, tz->id); 1743 + 1740 1744 kfree(tz->tzp); 1741 1745 kfree(tz); 1742 1746 }