Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5991568ybc; Wed, 27 Nov 2019 13:02:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzWtj8SbDSKLNA8X0vt5Sg6qOYKf8cpV61UR84XfoauoyyehlUkmbMlqJRjsrOtFYdAywLO X-Received: by 2002:a17:906:b253:: with SMTP id ce19mr25123741ejb.61.1574888563787; Wed, 27 Nov 2019 13:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888563; cv=none; d=google.com; s=arc-20160816; b=Ys25jNpHiZ15g0TjLTaDI3/Xs3XnUiLfi41J+dSz/hlpKJrOl736ybXnfPZvmk1UlO gGJ8Q6uqHfTteJNXx4p/58IAd5ibU3iP6h4gCrfOPFPS8fQek3bBe+tL8/gCihY2A0hL i9XLCEZ0XpuWxFpbdlGWoqsf2A5Z7nxJrQVdw9fAAq6Bv3VCeOt2+HF32IXlnVlFwq2M qwMXd4PHNqtRJKg3RXQ00Alv1AdTu00GBzqFxPrV95TBGx2t3YgT9nruAxSRcuI9UJV+ KtHy5Qy3Rg6+GhTcmzw7rHJohWUu02sBAUOaIl0wTsG3Pwf/vEiTVNFsOIttdBi0ZWby a+sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wZeJu6peKKEX2/+Pss6Z7VsuxBSp1nwq9+WCJR8NPsE=; b=hxFT0m+JaupcklSsm1eUjvGBMfIoYccc5QI15z+ZHiCw7uYvU90HM8PG5Nmwpi/fDB px2I22TBaBt69alaCxlpPKP+JbBwCPMmZ3VEGaU3+tzZ1wpOHa8+vQhYaysQWDHy+Xaz GB35yp7ytWQGASFhaUjgymfXJTiakY4TFP9yJD1dkoz+qMpDsRMpvlFg7V8FOF09mRfk Dyt9b7ivct1KfvrxP7FeJUCu+D9y2XJlr3AWdOsFqd17V/+mIN9m03Vlkf6U8DPGRXwL HW90YQcYOODAPiB0o6ZTd8tIcH2lto6Kva6rp067pyAEGTWIwY3OnHVvtA6fCX27RS7+ bIxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Czjg0EqR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si11517471edf.256.2019.11.27.13.02.18; Wed, 27 Nov 2019 13:02:43 -0800 (PST) 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=pass header.i=@kernel.org header.s=default header.b=Czjg0EqR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730616AbfK0U7T (ORCPT + 99 others); Wed, 27 Nov 2019 15:59:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:50642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731384AbfK0U7L (ORCPT ); Wed, 27 Nov 2019 15:59:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C0C1520678; Wed, 27 Nov 2019 20:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888350; bh=5Rj1jG5AzJgIvv4KhlSc3ZZrRvnb6Sthh2t/XsVj9iQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Czjg0EqRet18GzZ0KzmixOp+nySKUrCq9+i8RwnxZ+lde2cxMpaFNML27EmKaxwQL Qf80OLCZVI1N88+q27SvcE+yHTlUkb4B9LCOMtEVTtqU2wDBeaD/tblt2zV62p9I2n wsgXgJqAzWvTNHo2PNvN/Gccs6Au2uOdRWDmCxck= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Selvin Xavier , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 057/306] RDMA/bnxt_re: Avoid NULL check after accessing the pointer Date: Wed, 27 Nov 2019 21:28:27 +0100 Message-Id: <20191127203118.939326854@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Selvin Xavier [ Upstream commit eae4ad1b0c9a77ef0cbac212d58d46976eaacfc1 ] This is reported by smatch check. rcfw->creq_bar_reg_iomem is accessed in bnxt_qplib_rcfw_stop_irq and this variable check afterwards doesn't make sense. Also, rcfw->creq_bar_reg_iomem will never be NULL. So Removing this check. Reported-by: Dan Carpenter Fixes: 6e04b1035689 ("RDMA/bnxt_re: Fix broken RoCE driver due to recent L2 driver changes") Signed-off-by: Selvin Xavier Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c index 6637df77d2365..8b3b5fdc19bbb 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c @@ -614,13 +614,8 @@ void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) bnxt_qplib_rcfw_stop_irq(rcfw, true); - if (rcfw->cmdq_bar_reg_iomem) - iounmap(rcfw->cmdq_bar_reg_iomem); - rcfw->cmdq_bar_reg_iomem = NULL; - - if (rcfw->creq_bar_reg_iomem) - iounmap(rcfw->creq_bar_reg_iomem); - rcfw->creq_bar_reg_iomem = NULL; + iounmap(rcfw->cmdq_bar_reg_iomem); + iounmap(rcfw->creq_bar_reg_iomem); indx = find_first_bit(rcfw->cmdq_bitmap, rcfw->bmap_size); if (indx != rcfw->bmap_size) @@ -629,6 +624,8 @@ void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) kfree(rcfw->cmdq_bitmap); rcfw->bmap_size = 0; + rcfw->cmdq_bar_reg_iomem = NULL; + rcfw->creq_bar_reg_iomem = NULL; rcfw->aeq_handler = NULL; rcfw->vector = 0; } @@ -714,6 +711,8 @@ int bnxt_qplib_enable_rcfw_channel(struct pci_dev *pdev, dev_err(&rcfw->pdev->dev, "QPLIB: CREQ BAR region %d mapping failed", rcfw->creq_bar_reg); + iounmap(rcfw->cmdq_bar_reg_iomem); + rcfw->cmdq_bar_reg_iomem = NULL; return -ENOMEM; } rcfw->creq_qp_event_processed = 0; -- 2.20.1