From be7837e89d610046ae8dd28dc504df09261d9f91 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 14 Nov 2014 09:50:19 -0700 Subject: [PATCH] NVMe: fail pci initialization if the device doesn't have any BARs 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 Signed-off-by: Jens Axboe --- drivers/block/nvme-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index ba278ae00705..c1541652b7e0 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -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; -- 2.11.0