Skip to contentSkip to conversation

ACPICA: fix leak of acpi_os_validate_address

PATCH New Lin Ming 1 participant 1 message Jul 28, 2009

Subsystems (2)
lore
Share & tools
lore

Lin Ming

author
#0 lore raw

PATCH 2/2 ACPICA: fix leak of acpi_os_validate_address

Quoted 1 line

From b41e50dff230992745638749e37f5813487ffd4f Mon Sep 17 00:00:00 2001

From: Lin Ming <[email protected]>
Date: Tue, 28 Jul 2009 10:37:19 +0800
Subject: [PATCH] ACPICA: fix leak of acpi_os_validate_address

http://bugzilla.kernel.org/show_bug.cgi?id=13620

Reverting commit f9ca058 is on approach, but in looking at the code doing so could cause a memory leak.

1) add a new field "count" to struct acpi_res_list.

When inserting, if the region(addr, len) is already in the resource list, we just increase "count", otherwise, the region is inserted with count=1.

When deleting, the "count" is decreased, if it's decreased to 0, the region is deleted from the resource list.

With "count", the region with same address and length can only be inserted to the resource list once, so prevent potential memory leak.

2) add a new function acpi_os_invalidate_address, which is called when region is deleted.

---
 drivers/acpi/acpica/utdelete.c |    6 +++
 drivers/acpi/osl.c             |   93 ++++++++++++++++++++++++++++++++++++++-
 include/acpi/acpiosxf.h        |    4 ++
 3 files changed, 100 insertions(+), 3 deletions(-)
drivers/acpi/acpica/utdelete.c +6 -0
index bc17103..96e26e7 100644
@@ -215,6 +215,12 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
 				  "***** Region %p\n", object));
 
+		/* Invalidate the region address/length via the host OS */
+
+		acpi_os_invalidate_address(object->region.space_id,
+					  object->region.address,
+					  (acpi_size) object->region.length);
+
 		second_desc = acpi_ns_get_secondary_object(object);
 		if (second_desc) {
 			/*
drivers/acpi/osl.c +90 -3

122 lines not on this page · raw message

include/acpi/acpiosxf.h +4 -0
index ab0b85c..14d40bf 100644
@@ -246,6 +246,10 @@ acpi_status
 acpi_os_validate_address(u8 space_id, acpi_physical_address address,
 			 acpi_size length, char *name);
 
+acpi_status
+acpi_os_invalidate_address(u8 space_id, acpi_physical_address address,
+			 acpi_size length);
+
 u64 acpi_os_get_timer(void);
 
 acpi_status acpi_os_signal(u32 function, void *info);