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 9B72DC33CB3 for ; Thu, 16 Jan 2020 19:21:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D35A20661 for ; Thu, 16 Jan 2020 19:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579202489; bh=JJpE/7pU7nqNxioTDS0aMEeSILcg1XAsGFlPgkL1BP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JC7IF0rklY+LJ40GwoDxeLPpmvjseyZ/BsnvoIdvT3BToV/OcRS8p8hURzUQSpEM9 S0DWyRLzgsJ9wlOfveZg6og2yH4uxOw9WSLc6GhafOd1sWgXSY7m2E8GMEJ/ThK/NE fu0Kj67RoeShfTBFZ/0rC9skqQEXD9uqMj9V5Slg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437797AbgAPTV1 (ORCPT ); Thu, 16 Jan 2020 14:21:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:37722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729496AbgAPQxm (ORCPT ); Thu, 16 Jan 2020 11:53:42 -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 883FD2176D; Thu, 16 Jan 2020 16:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579193622; bh=JJpE/7pU7nqNxioTDS0aMEeSILcg1XAsGFlPgkL1BP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=glyZlwbhoiNUG47FfY3RZ5hOtWouoPkJS28OKjiwY+S9/Adk07DUk0fNPo5ILgtza QFTF9Q14yN58n+HBTp8k/LEQp7110+lsZYw5v9I3glUln66fOayJiqBXVqxDS2uep7 +QQ0XLP5R0Q9UYan/T7CBwlNhYs+jOAwmozf3AAI= 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 5.4 157/205] scsi: bnx2i: fix potential use after free Date: Thu, 16 Jan 2020 11:42:12 -0500 Message-Id: <20200116164300.6705-157-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116164300.6705-1-sashal@kernel.org> References: <20200116164300.6705-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: 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 c5fa5f3b00e9..0b28d44d3573 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