Skip to content

Commit 4b27d5c

Browse files
Dan Carpenterrafaeljw
authored andcommitted
ACPI: thermal: Fix acpi_thermal_unregister_thermal_zone() cleanup
The acpi_thermal_unregister_thermal_zone() is paired with acpi_thermal_register_thermal_zone() so it should mirror it. It should clean up all the resources that the register function allocated and leave the stuff that was allocated elsewhere. Unfortunately, it doesn't call thermal_zone_device_disable(). Also it calls kfree(tz->trip_table) when it shouldn't. That was allocated in acpi_thermal_add(). Putting the kfree() here leads to a double free in the acpi_thermal_add() clean up function. Likewise, the acpi_thermal_remove() should mirror acpi_thermal_add() so it should have an explicit kfree(tz->trip_table) as well. Fixes: ec23c1c ("ACPI: thermal: Use trip point table to register thermal zones") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f4cb34a commit 4b27d5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/acpi/thermal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,9 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
736736

737737
static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
738738
{
739+
thermal_zone_device_disable(tz->thermal_zone);
739740
acpi_thermal_zone_sysfs_remove(tz);
740741
thermal_zone_device_unregister(tz->thermal_zone);
741-
kfree(tz->trip_table);
742742
tz->thermal_zone = NULL;
743743
}
744744

@@ -1001,7 +1001,7 @@ static void acpi_thermal_remove(struct acpi_device *device)
10011001

10021002
flush_workqueue(acpi_thermal_pm_queue);
10031003
acpi_thermal_unregister_thermal_zone(tz);
1004-
1004+
kfree(tz->trip_table);
10051005
acpi_thermal_free_thermal_zone(tz);
10061006
}
10071007

0 commit comments

Comments
 (0)