public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [RFT PATCH] ACPICA: Fix memory leak caused by _CID repair function
@ 2021-04-28 22:52 Erik Kaneda
  2021-04-29 17:29 ` Kaneda, Erik
  2021-04-30 13:22 ` Shawn Guo
  0 siblings, 2 replies; 3+ messages in thread
From: Erik Kaneda @ 2021-04-28 22:52 UTC (permalink / raw)
  To: Rafael J . Wysocki, ACPI Devel Maling List, Shawn Guo,
	Gordon Ross
  Cc: Moore, Robert, Erik Kaneda

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).

Link: https://github.com/acpica/acpica/commit/5fc4f4b8

Signed-off-by: Erik Kaneda <erik.kaneda@intel.com>
---
 drivers/acpi/acpica/nsrepair2.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 14b71b41e845..38e10ab976e6 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -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++;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-30 13:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-28 22:52 [RFT PATCH] ACPICA: Fix memory leak caused by _CID repair function Erik Kaneda
2021-04-29 17:29 ` Kaneda, Erik
2021-04-30 13:22 ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox