Skip to content

Commit 827a075

Browse files
committed
thermal: core: Free tzp copy along with the thermal zone
The object pointed to by tz->tzp may still be accessed after being freed in thermal_zone_device_unregister(), so move the freeing of it to the point after the removal completion has been completed at which it cannot be accessed any more. Fixes: 3d439b1 ("thermal/core: Alloc-copy-free the thermal zone parameters structure") Cc: 6.8+ <stable@vger.kernel.org> # 6.8+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/4623516.LvFx2qVVIh@rjwysocki.net
1 parent a42a583 commit 827a075

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/thermal/thermal_core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,14 +1606,12 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
16061606
ida_destroy(&tz->ida);
16071607

16081608
device_del(&tz->device);
1609-
1610-
kfree(tz->tzp);
1611-
16121609
put_device(&tz->device);
16131610

16141611
thermal_notify_tz_delete(tz);
16151612

16161613
wait_for_completion(&tz->removal);
1614+
kfree(tz->tzp);
16171615
kfree(tz);
16181616
}
16191617
EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);

0 commit comments

Comments
 (0)