Patch "ACPI: thermal: Fix acpi_thermal_unregister_thermal_zone() cleanup" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ACPI: thermal: Fix acpi_thermal_unregister_thermal_zone() cleanup

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     acpi-thermal-fix-acpi_thermal_unregister_thermal_zon.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4d1a2397dfb5b11d74fd77072755b929cac3d4f2
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Tue Oct 31 12:53:06 2023 +0300

    ACPI: thermal: Fix acpi_thermal_unregister_thermal_zone() cleanup
    
    [ Upstream commit 4b27d5c420335dad7aea1aa6e799fe1d05c63b7e ]
    
    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: ec23c1c462de ("ACPI: thermal: Use trip point table to register thermal zones")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 312730f8272ee..8263508415a8d 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -778,9 +778,9 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 
 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
 {
+	thermal_zone_device_disable(tz->thermal_zone);
 	acpi_thermal_zone_sysfs_remove(tz);
 	thermal_zone_device_unregister(tz->thermal_zone);
-	kfree(tz->trip_table);
 	tz->thermal_zone = NULL;
 }
 
@@ -985,7 +985,7 @@ static void acpi_thermal_remove(struct acpi_device *device)
 
 	flush_workqueue(acpi_thermal_pm_queue);
 	acpi_thermal_unregister_thermal_zone(tz);
-
+	kfree(tz->trip_table);
 	kfree(tz);
 }
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux