diff options
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index da4bfbf95a7a..fb886d099baf 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -1253,7 +1253,7 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) | |||
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) { | 1255 | for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) { |
1256 | if (pci_resource_flags(pdev, i) & PCI_BASE_ADDRESS_SPACE_IO) { | 1256 | if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { |
1257 | if (pio_sz) | 1257 | if (pio_sz) |
1258 | continue; | 1258 | continue; |
1259 | pio_chip = (u64)pci_resource_start(pdev, i); | 1259 | pio_chip = (u64)pci_resource_start(pdev, i); |
@@ -1261,15 +1261,18 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) | |||
1261 | } else { | 1261 | } else { |
1262 | if (memap_sz) | 1262 | if (memap_sz) |
1263 | continue; | 1263 | continue; |
1264 | ioc->chip_phys = pci_resource_start(pdev, i); | 1264 | /* verify memory resource is valid before using */ |
1265 | chip_phys = (u64)ioc->chip_phys; | 1265 | if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) { |
1266 | memap_sz = pci_resource_len(pdev, i); | 1266 | ioc->chip_phys = pci_resource_start(pdev, i); |
1267 | ioc->chip = ioremap(ioc->chip_phys, memap_sz); | 1267 | chip_phys = (u64)ioc->chip_phys; |
1268 | if (ioc->chip == NULL) { | 1268 | memap_sz = pci_resource_len(pdev, i); |
1269 | printk(MPT2SAS_ERR_FMT "unable to map adapter " | 1269 | ioc->chip = ioremap(ioc->chip_phys, memap_sz); |
1270 | "memory!\n", ioc->name); | 1270 | if (ioc->chip == NULL) { |
1271 | r = -EINVAL; | 1271 | printk(MPT2SAS_ERR_FMT "unable to map " |
1272 | goto out_fail; | 1272 | "adapter memory!\n", ioc->name); |
1273 | r = -EINVAL; | ||
1274 | goto out_fail; | ||
1275 | } | ||
1273 | } | 1276 | } |
1274 | } | 1277 | } |
1275 | } | 1278 | } |