thermal/core: Delete device under thermal device zone lock
authorGuenter Roeck <linux@roeck-us.net>
Thu, 10 Nov 2022 15:24:53 +0000 (07:24 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 14 Nov 2022 18:04:37 +0000 (19:04 +0100)
commit30b2ae07d3d60a4f9763b08a1f696b789e777337
tree2949a4e19c8d7aaccd598ceab1697b17f46b7aae
parentd35f29ed9d11ccc4f9b957871d14726f4451a4ad
thermal/core: Delete device under thermal device zone lock

Thermal device attributes may still be opened after unregistering
the thermal zone and deleting the thermal device.

Currently there is no protection against accessing thermal device
operations after unregistering a thermal zone. To enable adding
such protection, protect the device delete operation with the
thermal zone device mutex. This requires splitting the call to
device_unregister() into its components, device_del() and put_device().
Only the first call can be executed under mutex protection, since
put_device() may result in releasing the thermal zone device memory.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c