]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
thermal: core: Fix thermal zone device registration error path
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 1 Apr 2026 14:33:53 +0000 (16:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Apr 2026 12:29:55 +0000 (14:29 +0200)
commit 9e07e3b81807edd356e1f794cffa00a428eff443 upstream.

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: 04e6ccfc93c5 ("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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/thermal/thermal_core.c

index a80a18cc080e364e8ca2be33eb829d4229151d90..3a19ae8fb5a01d33722baa353387690067c87660 100644 (file)
@@ -1638,6 +1638,7 @@ unregister:
        device_del(&tz->device);
 release_device:
        put_device(&tz->device);
+       wait_for_completion(&tz->removal);
 remove_id:
        ida_free(&thermal_tz_ida, id);
 free_tzp: