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=-5.7 required=3.0 tests=DATE_IN_PAST_03_06, 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 1BC94C33CAF for ; Wed, 22 Jan 2020 13:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCC89205F4 for ; Wed, 22 Jan 2020 13:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699767; bh=e36sjmPaCPPq1/i9Ltj188SqoWa1clYoefAn7mPbTaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=z5SbKNzQQ862mG8Y5UZjqAJ4hoNi2fpiQFbZnFoJVpRiUe/jg2s6R+FieQH5tZVCb 4QrvEYnaiMeKhkBOPxCa+nxb2YKj56UZ07qDnDAqKjpKYybBCLbsNA4Te+TKkfyrED f/pCWOghrY+0PZRI1qxInJ7APsj976wPVsPrMYo0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731065AbgAVN1V (ORCPT ); Wed, 22 Jan 2020 08:27:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:48472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730097AbgAVN1O (ORCPT ); Wed, 22 Jan 2020 08:27:14 -0500 Received: from localhost (unknown [84.241.205.26]) (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 D89DC2468C; Wed, 22 Jan 2020 13:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699633; bh=e36sjmPaCPPq1/i9Ltj188SqoWa1clYoefAn7mPbTaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hj0oPHg8m69oIlQBrTjsNjZmHcbYCz2ibsdF/aRfBXvJyv61Hx5BKlsSCPHgkMNc2 yWOrDOMo9f8N58DM1axldF3LDbpDvkB183DmPY8beYye+JsG0C1AoLQpeZjDE13Gev mPMuvZ+1QwA97xwGVCTyLN6bwfCCRiGfQ4BE4DY4= 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 5.4 203/222] scsi: bnx2i: fix potential use after free Date: Wed, 22 Jan 2020 10:29:49 +0100 Message-Id: <20200122092848.238314727@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@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);