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+ <[email protected]> # 6.8+ Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent a42a583 commit 827a075

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

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)