aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2015-05-20 22:31:12 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-05-21 21:22:20 -0400
commit2900d56ffb3bd23646db0d2562b6483329632e8a (patch)
tree54472615b1fb0ef5ed7a6df86e48668062b8c0bd /drivers/acpi/acpica
parentc8dec7459d9fcb880e5c42929d01c308bea9f823 (diff)
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-2143 Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/hwpci.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/acpi/acpica/hwpci.c b/drivers/acpi/acpica/hwpci.c
index c5214dec4988..f785ea788356 100644
--- a/drivers/acpi/acpica/hwpci.c
+++ b/drivers/acpi/acpica/hwpci.c
@@ -123,7 +123,7 @@ acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id,
123 acpi_handle root_pci_device, acpi_handle pci_region) 123 acpi_handle root_pci_device, acpi_handle pci_region)
124{ 124{
125 acpi_status status; 125 acpi_status status;
126 struct acpi_pci_device *list_head = NULL; 126 struct acpi_pci_device *list_head;
127 127
128 ACPI_FUNCTION_TRACE(hw_derive_pci_id); 128 ACPI_FUNCTION_TRACE(hw_derive_pci_id);
129 129
@@ -177,13 +177,13 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device,
177 acpi_handle parent_device; 177 acpi_handle parent_device;
178 acpi_status status; 178 acpi_status status;
179 struct acpi_pci_device *list_element; 179 struct acpi_pci_device *list_element;
180 struct acpi_pci_device *list_head = NULL;
181 180
182 /* 181 /*
183 * Ascend namespace branch until the root_pci_device is reached, building 182 * Ascend namespace branch until the root_pci_device is reached, building
184 * a list of device nodes. Loop will exit when either the PCI device is 183 * a list of device nodes. Loop will exit when either the PCI device is
185 * found, or the root of the namespace is reached. 184 * found, or the root of the namespace is reached.
186 */ 185 */
186 *return_list_head = NULL;
187 current_device = pci_region; 187 current_device = pci_region;
188 while (1) { 188 while (1) {
189 status = acpi_get_parent(current_device, &parent_device); 189 status = acpi_get_parent(current_device, &parent_device);
@@ -198,7 +198,6 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device,
198 /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */ 198 /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */
199 199
200 if (parent_device == root_pci_device) { 200 if (parent_device == root_pci_device) {
201 *return_list_head = list_head;
202 return (AE_OK); 201 return (AE_OK);
203 } 202 }
204 203
@@ -213,9 +212,9 @@ acpi_hw_build_pci_list(acpi_handle root_pci_device,
213 212
214 /* Put new element at the head of the list */ 213 /* Put new element at the head of the list */
215 214
216 list_element->next = list_head; 215 list_element->next = *return_list_head;
217 list_element->device = parent_device; 216 list_element->device = parent_device;
218 list_head = list_element; 217 *return_list_head = list_element;
219 218
220 current_device = parent_device; 219 current_device = parent_device;
221 } 220 }