From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18EA2C33CAF for ; Thu, 16 Jan 2020 17:16:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D856E20728 for ; Thu, 16 Jan 2020 17:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579194976; bh=EV2H9FdmuIxKETp3UbXatXCxMSaenovgJpwx9IU23EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ElFo4NNjPNqACstYJuYYtz/CDY6MLXj0tC/BaDheUdnWh+bTbUquvkU0mVLh/stXQ qwycMzPM3H0mNW70iKK0PnmOzJchalBrtukg6lYtU37JKxlY2iTTi5Z32uXdr7dhWX qxwR/jKndXYxSFx0gKdE+H4dJIW7Lo54fCMzWlcM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390922AbgAPRQL (ORCPT ); Thu, 16 Jan 2020 12:16:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:33076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390959AbgAPROS (ORCPT ); Thu, 16 Jan 2020 12:14:18 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 818FF246B7; Thu, 16 Jan 2020 17:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579194858; bh=EV2H9FdmuIxKETp3UbXatXCxMSaenovgJpwx9IU23EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0kqK3AmmWIc7/fgWSdnIOXa35iJTGFCyCUPv3ylRLUZHK0GWmQXLxWuYEivQL8/Qw ByZGQKRpYwDUjQE0IdIon6vhuQmtWHv0XVRJhboCQ1UD2S84PiNM1v5o0Sh0ioZeYT kasR+aeKPGePA7bg5UzfUcaWnZAFIyLp8/U2NuMg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pan Bian , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 653/671] scsi: bnx2i: fix potential use after free Date: Thu, 16 Jan 2020 12:04:51 -0500 Message-Id: <20200116170509.12787-390-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116170509.12787-1-sashal@kernel.org> References: <20200116170509.12787-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Pan Bian [ Upstream commit 29d28f2b8d3736ac61c28ef7e20fda63795b74d9 ] The member hba->pcidev may be used after its reference is dropped. Move the put function to where it is never used to avoid potential use after free issues. Fixes: a77171806515 ("[SCSI] bnx2i: Removed the reference to the netdev->base_addr") Link: https://lore.kernel.org/r/1573043541-19126-1-git-send-email-bianpan2016@163.com Signed-off-by: Pan Bian Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index de0a507577ef..718a0335cfbb 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -915,12 +915,12 @@ void bnx2i_free_hba(struct bnx2i_hba *hba) INIT_LIST_HEAD(&hba->ep_ofld_list); INIT_LIST_HEAD(&hba->ep_active_list); INIT_LIST_HEAD(&hba->ep_destroy_list); - pci_dev_put(hba->pcidev); if (hba->regview) { pci_iounmap(hba->pcidev, hba->regview); hba->regview = NULL; } + pci_dev_put(hba->pcidev); bnx2i_free_mp_bdt(hba); bnx2i_release_free_cid_que(hba); iscsi_host_free(shost); -- 2.20.1