Skip to content

Commit 04e6ccf

Browse files
committed
thermal: core: Fix NULL pointer dereference in zone registration error path
If device_register() in thermal_zone_device_register_with_trips() returns an error, the tz variable is set to NULL and subsequently dereferenced in kfree(tz->tzp). Commit adc8749 ("thermal/drivers/core: Use put_device() if device_register() fails") added the tz = NULL assignment in question to avoid a possible double-free after dropping the reference to the zone device. However, after commit 4649620 ("thermal: core: Make thermal_zone_device_unregister() return after freeing the zone"), that assignment has become redundant, because dropping the reference to the zone device does not cause the zone object to be freed any more. Drop it to address the NULL pointer dereference. Fixes: 3d439b1 ("thermal/core: Alloc-copy-free the thermal zone parameters structure") Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]>
1 parent 404f62c commit 04e6ccf

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
13931393
device_del(&tz->device);
13941394
release_device:
13951395
put_device(&tz->device);
1396-
tz = NULL;
13971396
remove_id:
13981397
ida_free(&thermal_tz_ida, id);
13991398
free_tzp:

0 commit comments

Comments
 (0)