PCI: acpiphp: check whether _ADR evaluation succeeded
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 20 Jun 2012 22:18:29 +0000 (16:18 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Oct 2012 20:28:03 +0000 (05:28 +0900)
commit dfb117b3e50c52c7b3416db4a4569224b8db80bb upstream.

Check whether we evaluated _ADR successfully.  Previously we ignored
failure, so we would have used garbage data from the stack as the device
and function number.

We return AE_OK so that we ignore only this slot and continue looking
for other slots.

Found by Coverity (CID 113981).

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
[bwh: Backported to 2.6.32/3.0: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/hotplug/acpiphp_glue.c

index a70fa89f76fdcbf20407747849ce75409f27f0c1..7bd36947deb3cba707d886d8012a57a4683790a2 100644 (file)
@@ -131,7 +131,12 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
        if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle))
                return AE_OK;
 
-       acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
+       status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
+       if (ACPI_FAILURE(status)) {
+               warn("can't evaluate _ADR (%#x)\n", status);
+               return AE_OK;
+       }
+
        device = (adr >> 16) & 0xffff;
        function = adr & 0xffff;