提交 2900d56f 编写于 作者: L Lv Zheng 提交者: Rafael J. Wysocki

ACPICA: Hardware: Fix a resource leak issue in acpi_hw_build_pci_list().

ACPICA commit e4f0b73c107680841d7dd01cc04ec108df6580bd

There is code in acpi_hw_build_pci_list() destructing returned object
(return_list_head) before touching it while the allocated new object
(list_head) is not tracked correctly to be destructed on the error case,
which is detected as unsecure code by the "Coverity" tool.

This patch fixes this issue by always intializing the returned object in
acpi_hw_build_pci_list() so that the caller of acpi_hw_build_pci_list() needn't
initialize it and always using the returned object to track the new
allocated objects. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/e4f0b73c
Link: https://jira01.devtools.intel.com/browse/LCK-2143Signed-off-by: NLv Zheng <lv.zheng@intel.com>
Signed-off-by: NBob Moore <robert.moore@intel.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 c8dec745
...@@ -123,7 +123,7 @@ acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id, ...@@ -123,7 +123,7 @@ acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id,
acpi_handle root_pci_device, acpi_handle pci_region) acpi_handle root_pci_device, acpi_handle pci_region)
{ {
acpi_status status; acpi_status status;
struct acpi_pci_device *list_head = NULL; struct acpi_pci_device *list_head;
ACPI_FUNCTION_TRACE(hw_derive_pci_id); ACPI_FUNCTION_TRACE(hw_derive_pci_id);
...@@ -177,13 +177,13 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device, ...@@ -177,13 +177,13 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device,
acpi_handle parent_device; acpi_handle parent_device;
acpi_status status; acpi_status status;
struct acpi_pci_device *list_element; struct acpi_pci_device *list_element;
struct acpi_pci_device *list_head = NULL;
/* /*
* Ascend namespace branch until the root_pci_device is reached, building * Ascend namespace branch until the root_pci_device is reached, building
* a list of device nodes. Loop will exit when either the PCI device is * a list of device nodes. Loop will exit when either the PCI device is
* found, or the root of the namespace is reached. * found, or the root of the namespace is reached.
*/ */
*return_list_head = NULL;
current_device = pci_region; current_device = pci_region;
while (1) { while (1) {
status = acpi_get_parent(current_device, &parent_device); status = acpi_get_parent(current_device, &parent_device);
...@@ -198,7 +198,6 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device, ...@@ -198,7 +198,6 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device,
/* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */ /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */
if (parent_device == root_pci_device) { if (parent_device == root_pci_device) {
*return_list_head = list_head;
return (AE_OK); return (AE_OK);
} }
...@@ -213,9 +212,9 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device, ...@@ -213,9 +212,9 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device,
/* Put new element at the head of the list */ /* Put new element at the head of the list */
list_element->next = list_head; list_element->next = *return_list_head;
list_element->device = parent_device; list_element->device = parent_device;
list_head = list_element; *return_list_head = list_element;
current_device = parent_device; current_device = parent_device;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册