]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
PCI: Fail pci_ioremap_bar() on unassigned resources
authorBjorn Helgaas <bhelgaas@google.com>
Thu, 12 Mar 2015 17:30:15 +0000 (12:30 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 12 Mar 2015 23:52:34 +0000 (18:52 -0500)
Make pci_ioremap_bar() fail if we're trying to map a BAR that hasn't been
assigned.

Normally pci_enable_device() will fail if a BAR hasn't been assigned, but a
driver can successfully call pci_enable_device_io() even if a memory BAR
hasn't been assigned.  That driver should not be able to use
pci_ioremap_bar() to map that unassigned memory BAR.

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

index a6d191ad9743555e6479d26664a2bf8ca408ece8..28df200bc54cf3b8db85f309553d7f64ee00f965 100644 (file)
@@ -131,7 +131,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
        /*
         * Make sure the BAR is actually a memory resource, not an IO resource
         */
-       if (!(res->flags & IORESOURCE_MEM)) {
+       if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) {
                dev_warn(&pdev->dev, "can't ioremap BAR %d: %pR\n", bar, res);
                return NULL;
        }