From patchwork Wed Jun 7 09:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 13270322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D08EC77B7A for ; Wed, 7 Jun 2023 09:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238859AbjFGJvn (ORCPT ); Wed, 7 Jun 2023 05:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234384AbjFGJvm (ORCPT ); Wed, 7 Jun 2023 05:51:42 -0400 X-Greylist: delayed 403 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 07 Jun 2023 02:51:39 PDT Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B55A7E49; Wed, 7 Jun 2023 02:51:39 -0700 (PDT) Received: from ed3e173716be.home.arpa (unknown [124.16.138.125]) by APP-03 (Coremail) with SMTP id rQCowACniR4dU4BkidqzDA--.1731S2; Wed, 07 Jun 2023 17:51:25 +0800 (CST) From: Jiasheng Jiang To: james.smart@broadcom.com, ram.vegesna@broadcom.com, jejb@linux.ibm.com, martin.petersen@oracle.com, chenzhongjin@huawei.com, dwagner@suse.de, hare@suse.de Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH v2] scsi: efct: Add missing check for ioremap Date: Wed, 7 Jun 2023 17:51:24 +0800 Message-Id: <20230607095124.38414-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: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SsGvfC2Kf nxnUUI43ZEXa7VUjC385UUUUU== X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org 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 --- 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]);