[PATCH v2] scsi: efct: Add missing check for ioremap

From: Jiasheng Jiang
Date: Wed Jun 07 2023 - 05:51:46 EST


Add check for ioremap() and return the error if it fails in order to
guarantee the success of ioremap().

Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
---
Changelog:

v1 -> v2:

1. Add "rc = -EINVAL;" in the error handling.
---
drivers/scsi/elx/efct/efct_driver.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/elx/efct/efct_driver.c b/drivers/scsi/elx/efct/efct_driver.c
index 49fd2cfed70c..8cb6d42b7432 100644
--- a/drivers/scsi/elx/efct/efct_driver.c
+++ b/drivers/scsi/elx/efct/efct_driver.c
@@ -528,6 +528,10 @@ efct_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) {
efct->reg[r] = ioremap(pci_resource_start(pdev, i),
pci_resource_len(pdev, i));
+ if (!efct->reg[r]) {
+ rc = -EINVAL;
+ goto ioremap_out;
+ }
r++;
}

@@ -580,7 +584,7 @@ efct_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
efct_teardown_msix(efct);
dma_mask_out:
pci_set_drvdata(pdev, NULL);
-
+ioremap_out:
for (i = 0; i < EFCT_PCI_MAX_REGS; i++) {
if (efct->reg[i])
iounmap(efct->reg[i]);
--
2.25.1