Skip to content

Commit 9e07e3b

Browse files
committed
thermal: core: Fix thermal zone device registration error path
If thermal_zone_device_register_with_trips() fails after registering a thermal zone device, it needs to wait for the tz->removal completion like thermal_zone_device_unregister(), in case user space has managed to take a reference to the thermal zone device's kobject, in which case thermal_release() may not be called by the error path itself and tz may be freed prematurely. Add the missing wait_for_completion() call to the thermal zone device registration error path. Fixes: 04e6ccf ("thermal: core: Fix NULL pointer dereference in zone registration error path") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: All applicable <stable@vger.kernel.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Tested-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/2849815.mvXUDI8C0e@rafael.j.wysocki
1 parent 45b859b commit 9e07e3b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/thermal/thermal_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,7 @@ thermal_zone_device_register_with_trips(const char *type,
16421642
device_del(&tz->device);
16431643
release_device:
16441644
put_device(&tz->device);
1645+
wait_for_completion(&tz->removal);
16451646
remove_id:
16461647
ida_free(&thermal_tz_ida, id);
16471648
free_tzp:

0 commit comments

Comments
 (0)