提交 fc193172 编写于 作者: R Richard A Lary 提交者: James Bottomley

[SCSI] mpt2sas: use correct pci_resource_flag for comparison

This patch replaces incorrect base address space flag with correct IO
resource flag.  Also, performs check of memory resource to validate
resource before using.
Signed-off-by: NRichard A Lary <rlary@linux.vnet.ibm.com>
Acked-by: N"Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
上级 4644efab
...@@ -1253,7 +1253,7 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) ...@@ -1253,7 +1253,7 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
} }
for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) { for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) {
if (pci_resource_flags(pdev, i) & PCI_BASE_ADDRESS_SPACE_IO) { if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
if (pio_sz) if (pio_sz)
continue; continue;
pio_chip = (u64)pci_resource_start(pdev, i); pio_chip = (u64)pci_resource_start(pdev, i);
...@@ -1261,15 +1261,18 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) ...@@ -1261,15 +1261,18 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
} else { } else {
if (memap_sz) if (memap_sz)
continue; continue;
ioc->chip_phys = pci_resource_start(pdev, i); /* verify memory resource is valid before using */
chip_phys = (u64)ioc->chip_phys; if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) {
memap_sz = pci_resource_len(pdev, i); ioc->chip_phys = pci_resource_start(pdev, i);
ioc->chip = ioremap(ioc->chip_phys, memap_sz); chip_phys = (u64)ioc->chip_phys;
if (ioc->chip == NULL) { memap_sz = pci_resource_len(pdev, i);
printk(MPT2SAS_ERR_FMT "unable to map adapter " ioc->chip = ioremap(ioc->chip_phys, memap_sz);
"memory!\n", ioc->name); if (ioc->chip == NULL) {
r = -EINVAL; printk(MPT2SAS_ERR_FMT "unable to map "
goto out_fail; "adapter memory!\n", ioc->name);
r = -EINVAL;
goto out_fail;
}
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册