Blob Blame History Raw
From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date: Thu, 30 Dec 2021 10:11:37 +0800
Subject: scsi: nsp_cs: Check of ioremap return value
Git-commit: 2576e153cd982d540b212e989458edc42ad1b390
Patch-mainline: v5.17-rc1
References: git-fixes

Since it is possible for ioremap() to fail, 'data->MmioAddress' could be
NULL. Skip entry if ioremap() fails.

[lduncan: refreshed to apply correctly]

Link: https://lore.kernel.org/r/20211230021137.1823352-1-jiasheng@iscas.ac.cn
Fixes: 0e6f9d270840 ("pcmcia: use pcmcia_loop_config in scsi pcmcia drivers")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Lee Duncan <lduncan@suse.com>
---
 drivers/scsi/pcmcia/nsp_cs.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1561,6 +1561,9 @@ static int nsp_cs_config_check(struct pc
 		data->MmioAddress = (unsigned long)
 			ioremap_nocache(p_dev->resource[2]->start,
 					resource_size(p_dev->resource[2]));
+		if (!data->MmioAddress)
+			goto next_entry;
+
 		data->MmioLength  = resource_size(p_dev->resource[2]);
 	}
 	/* If we got this far, we're cool! */