Skip to contentSkip to conversation

Fix acpi_ev_pci_config_region_setup() to avoid memory leak

PATCH In review Jesper Juhl 3 participants 3 messages Jul 18, 2007 – Jul 19, 2007 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix acpi_ev_pci_config_region_setup() to avoid memory leak

Hello,

In drivers/acpi/events/evrgnini.c::acpi_ev_pci_config_region_setup() there is a memory leak.
We may return at "if (!pci_device_node)" without freeing storage previously allocated and assigned to 'pci_id'.
This patch fixes the leak by freeing the allocated storage in this case.

Compile tested only...

---

 drivers/acpi/events/evrgnini.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/acpi/events/evrgnini.c +1 -0
index 400d90f..10f378b 100644
@@ -284,6 +284,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
 	}
 
 	if (!pci_device_node) {
+		kfree(pci_id);
 		return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
 	}
 
reviewer
#1 lore raw
Quoted 1 line · Jesper Juhl

drivers/acpi/events/evrgnini.c

applied (after changing to ACPI_FREE())

thanks,
-Len

#2 lore raw
In reply to Jesper Juhl
Quoted 23 lines · On Thu, 19 Jul 2007 00:48:03 +0200 Jesper Juhl <[email protected]> wrote:

Hello,

In drivers/acpi/events/evrgnini.c::acpi_ev_pci_config_region_setup() there is a memory leak.
We may return at "if (!pci_device_node)" without freeing storage previously allocated and assigned to 'pci_id'.
This patch fixes the leak by freeing the allocated storage in this case.

Compile tested only...

---

 drivers/acpi/events/evrgnini.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/acpi/events/evrgnini.c +0 -0
index 400d90f..10f378b 100644

drivers/acpi/events/evrgnini.c acpi_ev_pci_config_region_setup(acpi_handle handle, · line 290

Quoted 7 lines
drivers/acpi/events/evrgnini.c +1 -0
@@ -284,6 +284,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
 	}
 
 	if (!pci_device_node) {
+		kfree(pci_id);
 		return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
 	}
 

We're supposed to use the attractive ACPI_FREE() here. I'll make that change.