Skip to content

Commit 72c1aff

Browse files
committed
thermal/debugfs: Free all thermal zone debug memory on zone removal
Because thermal_debug_tz_remove() does not free all memory allocated for thermal zone diagnostics, some of that memory becomes unreachable after freeing the thermal zone's struct thermal_debugfs object. Address this by making thermal_debug_tz_remove() free all of the memory in question. Fixes: 7ef01f2 ("thermal/debugfs: Add thermal debugfs information for mitigation episodes") Cc :6.8+ <[email protected]> # 6.8+ Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]>
1 parent ed30a4a commit 72c1aff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/thermal/thermal_debugfs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,15 +826,28 @@ void thermal_debug_tz_add(struct thermal_zone_device *tz)
826826
void thermal_debug_tz_remove(struct thermal_zone_device *tz)
827827
{
828828
struct thermal_debugfs *thermal_dbg = tz->debugfs;
829+
struct tz_episode *tze, *tmp;
830+
struct tz_debugfs *tz_dbg;
831+
int *trips_crossed;
829832

830833
if (!thermal_dbg)
831834
return;
832835

836+
tz_dbg = &thermal_dbg->tz_dbg;
837+
833838
mutex_lock(&thermal_dbg->lock);
834839

840+
trips_crossed = tz_dbg->trips_crossed;
841+
842+
list_for_each_entry_safe(tze, tmp, &tz_dbg->tz_episodes, node) {
843+
list_del(&tze->node);
844+
kfree(tze);
845+
}
846+
835847
tz->debugfs = NULL;
836848

837849
mutex_unlock(&thermal_dbg->lock);
838850

839851
thermal_debugfs_remove_id(thermal_dbg);
852+
kfree(trips_crossed);
840853
}

0 commit comments

Comments
 (0)