]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NVMe: fail pci initialization if the device doesn't have any BARs
authorJens Axboe <axboe@fb.com>
Fri, 14 Nov 2014 16:50:19 +0000 (09:50 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 20 Nov 2014 18:10:06 +0000 (11:10 -0700)
The PCI init of NVMe doesn't check for valid bars before proceeding
to map and use BAR 0. If the device is hosed (or firmware is), then
we should catch this case and give up early.

This fixes a:

[ 1662.035778] WARNING: CPU: 0 PID: 4 at arch/x86/mm/ioremap.c:63 __ioremap_check_ram+0xa7/0xc0()

and later badness on such a device.

Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/nvme-core.c

index ba278ae007052731c708e907a174fb4243470884..c1541652b7e03c1cb9dd65dc1f32bc93448e4e08 100644 (file)
@@ -2156,6 +2156,9 @@ static int nvme_dev_map(struct nvme_dev *dev)
        dev->entry[0].vector = pdev->irq;
        pci_set_master(pdev);
        bars = pci_select_bars(pdev, IORESOURCE_MEM);
+       if (!bars)
+               goto disable_pci;
+
        if (pci_request_selected_regions(pdev, bars, "nvme"))
                goto disable_pci;