PCI/ACPI: Check acpi_resource_to_address64() return value
authorBjorn Helgaas <bhelgaas@google.com>
Fri, 22 Jun 2012 05:48:50 +0000 (23:48 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 15 May 2013 16:51:14 +0000 (10:51 -0600)
We should check the acpi_resource_to_address64() return value, which
also removes the need to validate the resource type beforehand.
No functional change.

Found by Coverity (CID 113815).

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/pci_root.c

index 1dd6f6c8587442ab1fcbdf7d7bd78d98ef551a9b..f6c0998f248ad52ed559332305351ffa3cac96af 100644 (file)
@@ -100,13 +100,12 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
 {
        struct resource *res = data;
        struct acpi_resource_address64 address;
+       acpi_status status;
 
-       if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
-           resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
-           resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
+       status = acpi_resource_to_address64(resource, &address);
+       if (ACPI_FAILURE(status))
                return AE_OK;
 
-       acpi_resource_to_address64(resource, &address);
        if ((address.address_length > 0) &&
            (address.resource_type == ACPI_BUS_NUMBER_RANGE)) {
                res->start = address.minimum;