Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1845088imm; Thu, 14 Jun 2018 04:58:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJSbkEaV6mh8HhCZBHBXx0z4ckjBPPQBI8Nshmr9VNYiF9FDWH8A46RTj0ZOV9NNp3xdifA X-Received: by 2002:a17:902:5a87:: with SMTP id r7-v6mr2686821pli.78.1528977503958; Thu, 14 Jun 2018 04:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528977503; cv=none; d=google.com; s=arc-20160816; b=X/j1f516ODORjA0LiGrj29zpvAo/u6GblSTG19VBw3GE2Fk//cIfmYEaSAn7IPK3IV EqVtvXJaD6YIMSnAmAGdqM9EI+o4q9+qjEP9m1i9LjmEb5WYx+0pLEgQMTw3gez4ywtR 7g70Ch8XSFbwIe7Nn6769iNqf+RSY7gutV5m6UFIJM/OaIjcV0iO5q9FKwhaxSz5hK/l MbFQqy3yLxa+lEnGnz7yACXCee3FuJiGJgeG3ndvBKgPkHHePOHxQgJuEqCS94csvv3y ljfQ3xTipLJ98BIPFDcI8MH27QUQSZf3eXj1Jw0eabZJxXfDoSM5EuslH0GSA7j5q0fz ut9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=iaWQ/sZl61trrDNq5l36xcWF9Q9vzGPTiusYs3uvq/M=; b=e+3UzO8v9foJVsvcv3U2Eb4uhAZiA/ZZuPd5ciN/uRPMavGA3XGqjcq3hHCSUIihs9 B5EPRCr28Rey327QMDaQPIKa5bI71P3mZpUjAjjb5DsDR/IrsU6s5MxxRtTe99D2BTTW xUf2UjuBVMlhUpsZWrfKO17nZuYrRj3UmD+TZo1N/HSh70B3IZ3eeuec57xd8HtB9p1Y msSTolH/3747HPF9p1a/KjNJJzc8dSnLl1iV0Bf1+aS9J8OjznaSjYB8BTKfClJeSePx NIovLabtw+2HcmKu1NSLkkTKcDLO6vFkaesFyg9Ls2zliRbYoVyZVidwxjlsoEiZakQk 1+iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="h47y/+X2"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y36-v6si383702pga.89.2018.06.14.04.58.09; Thu, 14 Jun 2018 04:58:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="h47y/+X2"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755072AbeFNL5q (ORCPT + 99 others); Thu, 14 Jun 2018 07:57:46 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:39557 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754912AbeFNL5p (ORCPT ); Thu, 14 Jun 2018 07:57:45 -0400 Received: by mail-pf0-f193.google.com with SMTP id r11-v6so3128724pfl.6; Thu, 14 Jun 2018 04:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iaWQ/sZl61trrDNq5l36xcWF9Q9vzGPTiusYs3uvq/M=; b=h47y/+X2sfWB1l7Cg7CVTBcDk3eRmY3mPjFyER8Tzz8PCjDK0Y95gGsx8O7G5LDCJJ KDBcaFtFllUlaWa6tvgfZ349cAWVwUcVFsDrPr4N+A6V/1OUDsOWqcyO+UNYQKPzj9qu GdwSHfIDJGpwaiRH41I5CWQZ5raZcewTnek4TPxpxlktf7EkYwEjb/6FwU4cjVWQzne9 UObOMd9Ch+sALK4NZ7W3IaNLA/99rGd7DYDqM3fvv/yfWnmh4QFVQYYwyCoxN3RG2wMs 4vi/erLGqjTvFbAqPwaoJxP+p2l4XF/a9c9SBKvQppTov+oOaKq0B9lxbjQPGBfdqJwl WmXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iaWQ/sZl61trrDNq5l36xcWF9Q9vzGPTiusYs3uvq/M=; b=p6+oUsJsIBbmjFmMyp/5Wp0my4SfYR9QNqHjjBNI9VE7SB5mhOzYvrvqucHDh/pzWA tCzeL/3HNQ6FpiKe/SiE1pULDyjEWUcI0JfN0ad2SZ6A6CEDlI4drg+tuv7TyenhN3tu nJMRnVy8YUo402ddLJq4ImVM/KHw0aU8zlUuDxNJs6vkr+FLorHBm8QrrKba+Dg9f5xf 4yYGtN6k/C+g+jqgEK154CaDl2EM31qzRpWRJ+cF0dzRGryVljJnebm+SBIhV+YR4Yg0 M/TLbFJa8dEIk6//beX8bgSPd4RPaWEHBQDp4KibY+brGeGKEyvy6IA8dZ8cPoun0xqc t+DA== X-Gm-Message-State: APt69E3cHIBKMCynvWtGnN7uX/kA421f5bni7s4j03WOO9F4HNTfjAZo xou5UEihk6F7UZ1GMVI/BiF9bRQUp8o= X-Received: by 2002:a63:6d0:: with SMTP id 199-v6mr2035984pgg.338.1528977464493; Thu, 14 Jun 2018 04:57:44 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id h27-v6sm14386150pfk.160.2018.06.14.04.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 04:57:43 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Anil Gurumurthy , Sudarsana Kalluru , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] scsi: bfa: add error handling for pci_iomap Date: Thu, 14 Jun 2018 19:57:39 +0800 Message-Id: <1528977459-52285-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528705581-34646-1-git-send-email-jiazhouyang09@gmail.com> References: <1528705581-34646-1-git-send-email-jiazhouyang09@gmail.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When pci_iomap fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling pci_iomap. Signed-off-by: Zhouyang Jia --- v1->v2: - Unmap bfad->pci_bar0_kva. --- drivers/scsi/bfa/bfad.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index bd7e6a6f..693e180 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -760,6 +760,11 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) goto out_release_region; } + if (bfad->pci_bar2_kva == NULL) { + printk(KERN_ERR "Fail to map bar2\n"); + goto out_unmap_bar0; + } + bfad->hal_pcidev.pci_slot = PCI_SLOT(pdev->devfn); bfad->hal_pcidev.pci_func = PCI_FUNC(pdev->devfn); bfad->hal_pcidev.pci_bar_kva = bfad->pci_bar0_kva; @@ -797,6 +802,8 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) return 0; +out_unmap_bar0: + pci_iounmap(pdev, bfad->pci_bar0_kva); out_release_region: pci_release_regions(pdev); out_disable_device: -- 2.7.4