summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-14 13:52:25 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-26 02:35:15 +0300
commit335176dd8ebaca6493807dceea33c478305667fa (patch)
tree42188b15145d01cbb208240b5594cc620f68edee /drivers/thermal
parentc4323f66f39ee6a658bc80b848f6af7721306fea (diff)
downloadlinux-335176dd8ebaca6493807dceea33c478305667fa.tar.xz
thermal: core: Fix NULL pointer dereference in zone registration error path
[ Upstream commit 04e6ccfc93c5a1aa1d75a537cf27e418895e20ea ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/thermal')
-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 e6f3166a9208..2de524fb7be5 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1382,7 +1382,6 @@ unregister:
device_del(&tz->device);
release_device:
put_device(&tz->device);
- tz = NULL;
remove_id:
ida_free(&thermal_tz_ida, id);
free_tzp: