ACPICA: fix leak of acpi_os_validate_address
Subsystems (2)
PATCH RESEND 1/1 ACPICA: fix leak of acpi_os_validate_address
From: Lin Ming <[email protected]>
Date: Thu, 13 Aug 2009 10:43:27 +0800
Subject: [PATCH] ACPICA: fix leak of acpi_os_validate_address
http://bugzilla.kernel.org/show_bug.cgi?id=13620
If the dynamic region is created and added to resource list over and over again, it has the potential to be a memory leak by growing the list every time.
This patch fixes the memory leak, as below
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 | 94 ++++++++++++++++++++++++++++++++++++++- include/acpi/acpiosxf.h | 4 ++ 3 files changed, 101 insertions(+), 3 deletions(-)
drivers/acpi/acpica/utdelete.c +6 -0
@@ -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 +91 -3
123 lines not on this page · raw message
include/acpi/acpiosxf.h +4 -0
@@ -242,6 +242,10 @@ acpi_os_derive_pci_id(acpi_handle rhandle,acpi_status acpi_os_validate_interface (char *interface);acpi_status acpi_osi_invalidate (char * interface); +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);
Quoted 20 lines · Lin Ming
From: Lin Ming <[email protected]>
Date: Thu, 13 Aug 2009 10:43:27 +0800
Subject: [PATCH] ACPICA: fix leak ofacpi_os_validate_addresshttp://bugzilla.kernel.org/show_bug.cgi?id=13620
If the dynamic region is created and added to resource list over and over again, it has the potential to be a memory leak by growing the list every time.
This patch fixes the memory leak, as below
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.
Quoted 7 lines
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.Signed-off-by Lin Ming <[email protected]>
Forgot to mention that it's applied on top of 2.6.31-rc5.
Lin Ming
Len Brown
reviewerit is easier to apply patches when they do not appear multiple times in the e-mail message...
why does acpi_os_invalidate_address() need a return value other than void?
applied to acpi-test
thanks,
Len Brown, Intel Open Source Technology Center
Quoted 4 lines · Len Brown
it is easier to apply patches when they do not appear multiple times in the e-mail message...
why does
acpi_os_invalidate_address()need a return value other than void?
Just for extension, maybe some future usage.
Lin Ming
Quoted 6 lines
applied to acpi-test
thanks,
Len Brown, Intel Open Source Technology Center