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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 4E859C33CAF for ; Wed, 22 Jan 2020 09:39:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CE9F24686 for ; Wed, 22 Jan 2020 09:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685986; bh=e36sjmPaCPPq1/i9Ltj188SqoWa1clYoefAn7mPbTaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mmupGFmy/ZPCfzEMmi1xDjIhellQViDny4o243Liuugnq06n+Of0MJmgT2ci5pr16 KB4JTcA+kCgzU58R/r6xwhL6PG+PIWpCmfs1VsWg/2MGmykgsomPkITibWnHitUVXC DGRdoKc8KJL5nYrtMVzHtbhAMi5BVEnCB9EGQwOY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733079AbgAVJjo (ORCPT ); Wed, 22 Jan 2020 04:39:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:57838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732572AbgAVJjk (ORCPT ); Wed, 22 Jan 2020 04:39:40 -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 DB6912467B; Wed, 22 Jan 2020 09:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685980; bh=e36sjmPaCPPq1/i9Ltj188SqoWa1clYoefAn7mPbTaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wmKXIYpQI4yjC7Z0WovD3x8XMnmYE63miJRwNQGNa7iHhh1c4ofASQQKDyDgV36tp lgw2tOjc5OEKsb+6JjbuVK4hy2xTaWRw5OCqvsGm7bk/GkvkNRAYHSrlMgQax5V5sM XjF+P6R0zlOA7S6RkY8Jbwl4cnyO46qhtNtOz7ps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , "Martin K. Petersen" Subject: [PATCH 4.14 59/65] scsi: bnx2i: fix potential use after free Date: Wed, 22 Jan 2020 10:29:44 +0100 Message-Id: <20200122092800.251654611@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092750.976732974@linuxfoundation.org> References: <20200122092750.976732974@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: Pan Bian commit 29d28f2b8d3736ac61c28ef7e20fda63795b74d9 upstream. 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: Greg Kroah-Hartman --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 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 *hb 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);