summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_core.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-14 11:52:25 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-15 18:24:24 +0100
commit04e6ccfc93c5a1aa1d75a537cf27e418895e20ea (patch)
treee583fb217601df44aa455556558315a9539c7114 /drivers/thermal/thermal_core.c
parent404f62cd6407f163e03cfaca97e27c1c4c62eb3c (diff)
downloadlinux-stable-04e6ccfc93c5a1aa1d75a537cf27e418895e20ea.tar.gz
linux-stable-04e6ccfc93c5a1aa1d75a537cf27e418895e20ea.tar.bz2
linux-stable-04e6ccfc93c5a1aa1d75a537cf27e418895e20ea.zip
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 adc8749b150c ("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 4649620d9404 ("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: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Diffstat (limited to 'drivers/thermal/thermal_core.c')
-rw-r--r--drivers/thermal/thermal_core.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 2415dc50c31d..5e5fcbd81dda 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1393,7 +1393,6 @@ unregister:
device_del(&tz->device);
release_device:
put_device(&tz->device);
- tz = NULL;
remove_id:
ida_free(&thermal_tz_ida, id);
free_tzp: