ACPICA: Fix memory leak caused by _CID repair function
Subsystems (2)
PATCH 1/1 ACPICA: Fix memory leak caused by _CID repair function
ACPICA commit 5fc4f4b87d6890d48d050ab279ed01f0132662ca
According to the ACPI spec, _CID returns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself.
Name (TEST, Package() {
"String object" // this package element has a reference count of 2
})
A memory leak was caused in the _CID repair function because it did not decrement the reference count created by the package. Fix the memory leak by calling acpi_ut_remove_reference on _CID package elements that represent a hardware ID (_HID).
--- drivers/acpi/acpica/nsrepair2.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/acpica/nsrepair2.c +7 -0
@@ -379,6 +379,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, (*element_ptr)->common.reference_count = original_ref_count; + +/* +* The original_element holds a reference from the package object +* that represents _HID. Since a new element was created by _HID, +* remove the reference from the _CID package. +*/ +acpi_ut_remove_reference (original_element); } element_ptr++;
Signature · 1 line
2.29.2
Shawn,
Could you test this patch using the setup that you used to report the crash?
https://github.com/acpica/acpica/commit/d095b337ae1f107ad66bec19a99b4d7affae2fc4
Thanks,
Erik
Quoted 56 lines
-----Original Message-----
From: Kaneda, Erik <[email protected]>
Sent: Wednesday, April 28, 2021 3:53 PM
To: Rafael J . Wysocki <[email protected]>; ACPI Devel Maling List <linux- [email protected]>; Shawn Guo <[email protected]>; Gordon Ross <[email protected]>
Cc: Moore; Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>
Subject: [RFT PATCH] ACPICA: Fix memory leak caused by_CIDrepair functionACPICA commit
5fc4f4b87d6890d48d050ab279ed01f0132662caAccording to the ACPI spec,
_CIDreturns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself.Name (TEST,
Package(){
"String object" // this package element has a reference count of 2
})A memory leak was caused in the
_CIDrepair function because it did not decrement the reference count created by the package. Fix the memory leak by callingacpi_ut_remove_referenceon_CIDpackage elements
that represent a hardware ID (_HID).Signed-off-by Erik Kaneda <[email protected]>--- drivers/acpi/acpica/nsrepair2.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/acpi/acpica/nsrepair2.c +3
-0@@ -379,6 +379,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, (*element_ptr)->common.reference_count = original_ref_count; + +/* +* The original_element holds a reference from the package object
drivers/acpi/acpica/nsrepair2.c +1
-0+* that represents _HID. Since a new element was created by
_HID,drivers/acpi/acpica/nsrepair2.c +3
-1+* remove the reference from the _CID package. +*/ +acpi_ut_remove_reference (original_element); } element_ptr++; --2.29.2
Quoted 10 lines · Erik Kaneda
ACPICA commit
5fc4f4b87d6890d48d050ab279ed01f0132662caAccording to the ACPI spec,
_CIDreturns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself.Name (TEST,
Package(){
"String object" // this package element has a reference count of 2
})
Quoted 8 lines
A memory leak was caused in the
_CIDrepair function because it did not decrement the reference count created by the package. Fix the memory leak by callingacpi_ut_remove_referenceon_CIDpackage elements that represent a hardware ID (_HID).Signed-off-by Erik Kaneda <[email protected]>
Tested on Snapdragon laptops, and nothing seems broken.