Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp777874ybc; Sat, 16 Nov 2019 08:31:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwncLg9e0SZPz1Ea/dSHwuMQjMsdrrsB3GWlfguE7ps7RijoPa25ohWY1sP9k3Mczvv87wm X-Received: by 2002:a17:906:11cd:: with SMTP id o13mr10818895eja.272.1573921869793; Sat, 16 Nov 2019 08:31:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921869; cv=none; d=google.com; s=arc-20160816; b=UZMSexDBZTVO+7t5WNP/4VllWxLFjVObXp6EzP9rAu3Cpy2JiqPAfcAtDH7a2EM3o5 zHOGjlEjyWoZe4SvMqf7qkBsEkrZLghAwmjIj3haF2n1z+8uQBztF5Yb526EoHnD4YUH jJ0TK7S8XrFGgq5GrfxmhiB1YY3QVdn/AHZ/+1gcTt0ZzFnlXcq9eR7scSaYHy/CCsTE nj5xtr2ljITGm+xnRkZ+LhAG8EHIlcdffy1SXXPKFpeXMh7LXCt1GGHRVsYhShVwkxW8 Hgknq0z5wDUJEGLdqcoap7uG8s3PAtPdebDxsAuimLlt/PGhNgv4eZ5fp7R1jeuj+GzU 1OLA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wZeJu6peKKEX2/+Pss6Z7VsuxBSp1nwq9+WCJR8NPsE=; b=Li9kjIp2cURUfoaIuIrXkhuTOV/BSRULsw2YZfLiqV9DufFvpXGGgSYDeozM56GNBN 1PPK62cCQvng/iEBLvfiiOGDRJSNCFeZjFqYI+X1yt5hH+ckqFAYhszin/3f3KqTa3V7 vUKQHO9kg7jhqcZwmETEOOsCfhcPvllR3apVVAd5wb+Py+tAffajDwIMeho8FUA3iLcS DJTD/Rj/f5Lf6IrEFJ5UiA3g79CuqwqeVJMP4hCi4a5dKdRMJdpJrYiU9kgBz/7fs3M1 /br33Q+kUihSOf5p9IS9EPCBm1V19pVgKKrBD0Qj70EgmD2c8nYpdLhkdsgAancfAnhw 0fFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AohsvXII; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si7592582ejj.367.2019.11.16.08.30.44; Sat, 16 Nov 2019 08:31:09 -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=AohsvXII; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728077AbfKPPl6 (ORCPT + 99 others); Sat, 16 Nov 2019 10:41:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:45292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728042AbfKPPl4 (ORCPT ); Sat, 16 Nov 2019 10:41:56 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CF9020740; Sat, 16 Nov 2019 15:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918915; bh=5Rj1jG5AzJgIvv4KhlSc3ZZrRvnb6Sthh2t/XsVj9iQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AohsvXIIBUS/tAuy7LCnQk6sL3NRTht3UKmgkX9Q7TDlvXx78jTlR8sFSrDJsEgLi 8egeh5iaXqjKbQ3ozGNK/kTtbLfpyQnpGlOSGoFnuhr7Nub2bUsJl0vD7XQ3nIwV/9 OjIVHO9GyZdgqpQ7PRsevsWFsHcM2k/aMQOMcv2c= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Selvin Xavier , Dan Carpenter , Jason Gunthorpe , Sasha Levin , linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 038/237] RDMA/bnxt_re: Avoid NULL check after accessing the pointer Date: Sat, 16 Nov 2019 10:37:53 -0500 Message-Id: <20191116154113.7417-38-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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