Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654355pxb; Mon, 24 Jan 2022 14:32:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpvwmD9w0mA4gkGJ1+sHtcSotAQkTSgTh4e84m/MN+BPsxu/AzGOvsqAp1TyEqzFS3bXct X-Received: by 2002:a17:902:70c9:b0:149:76f1:47dc with SMTP id l9-20020a17090270c900b0014976f147dcmr15999862plt.130.1643063547727; Mon, 24 Jan 2022 14:32:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063547; cv=none; d=google.com; s=arc-20160816; b=Wx7MP+6Lkgvb5z62cisKH8s/zE07TGTmvXiac1KGyyfSGHBg+/3dq8Rd9HZ6ustvK+ 6q8edV/fQtRj86893JmT9Pq1VdNa/pVc4XBie7n4YZxLZGa71IYh1E9h/EWE2STRcN9i k92BLy0v0a+lKrqZtP0kiC7Gs+IeRkUDK7ebZ1DxUH/GGlIMQMgVZYShRHM5rHbuiI1t JXsKmXvPT78o8iQWchI7aJ91VzPlgZngMT2MkmJixoz3FtbDo2yaB2PvEJl9CN8YOrEY tYPNpf5YEkUiUW+Fbkmgq56YcAcoW9DuqPoVgP970bghcBlkPHCDm2kpqr0gJ30QFcSb RtpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xK8EZn5OeN+potbbmJ4xyQdy1aR38COr64tPfRizLmI=; b=sJxbP7cP7Ogm1nqZVpV6tlW4qjLRppurkH/YuP7kD2g20qw/EUVPF/QJH9mgrROY3U ALTb5E3hYqA2VV0IIDfN4x5ypKwV1B57XYL5dElbAMYD3TUf3M/pJ8IiaoKYWbKrKTNc ybdFL5MZKRwEwkLT0mqpW+q6o6pKQZH57YkGcii2oNAyhMofY6CQonDct6k70N1ZgY19 HmNI5w18nX/VTa0C61b0VUilA+xfofpeUYcjT9ucG3dxSZd41Xb7SksI3pLDKKDKcdY+ AbYYPUOAFkXpfeaPxIrvSCWbquIR9EUSQJWjrVVgBWhckretT8HIwtDMrusQot/Wq1MW szRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OoMghYkZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e36si13870874pge.147.2022.01.24.14.32.15; Mon, 24 Jan 2022 14:32:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OoMghYkZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1586345AbiAXW0Q (ORCPT + 99 others); Mon, 24 Jan 2022 17:26:16 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:51424 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1453775AbiAXVay (ORCPT ); Mon, 24 Jan 2022 16:30:54 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F71A614DD; Mon, 24 Jan 2022 21:30:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7A7FC340E7; Mon, 24 Jan 2022 21:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059851; bh=PVz8ZLaocFB/t0tWMTtejzI8NBaFzsQAP49wgSYBZck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoMghYkZMvsWBRrs4lRyGxHTP0niN1mzwX7Slqele+2yX0yRFg3o/Jr2HRnV8W89v +a8+QdPzR9S0vbv14jTZj0ot7vCqf1IuFKO8dRpSrCCG5ztTYw2eyfUKy0syei6InN Q1OaCcnyRhEKuPFFEfbrmg+tKDfJjhhtelK5yIXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Justin Tee , James Smart , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.16 0754/1039] scsi: lpfc: Fix leaked lpfc_dmabuf mbox allocations with NPIV Date: Mon, 24 Jan 2022 19:42:23 +0100 Message-Id: <20220124184150.679689672@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Smart [ Upstream commit f0d3919697492950f57a26a1093aee53880d669d ] During rmmod testing, messages appeared indicating lpfc_mbuf_pool entries were still busy. This situation was only seen doing rmmod after at least 1 vport (NPIV) instance was created and destroyed. The number of messages scaled with the number of vports created. When a vport is created, it can receive a PLOGI from another initiator Nport. When this happens, the driver prepares to ack the PLOGI and prepares an RPI for registration (via mbx cmd) which includes an mbuf allocation. During the unsolicited PLOGI processing and after the RPI preparation, the driver recognizes it is one of the vport instances and decides to reject the PLOGI. During the LS_RJT preparation for the PLOGI, the mailbox struct allocated for RPI registration is freed, but the mbuf that was also allocated is not released. Fix by freeing the mbuf with the mailbox struct in the LS_RJT path. As part of the code review to figure the issue out a couple of other areas where found that also would not have released the mbuf. Those are cleaned up as well. Link: https://lore.kernel.org/r/20211204002644.116455-2-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_els.c | 6 +++++- drivers/scsi/lpfc/lpfc_init.c | 8 ++++++-- drivers/scsi/lpfc/lpfc_nportdisc.c | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index e83453bea2aee..5c10416c1c75a 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -6899,6 +6899,7 @@ static int lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) { LPFC_MBOXQ_t *mbox = NULL; + struct lpfc_dmabuf *mp; int rc; mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); @@ -6914,8 +6915,11 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0; mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) + if (rc == MBX_NOT_FINISHED) { + mp = (struct lpfc_dmabuf *)mbox->ctx_buf; + lpfc_mbuf_free(phba, mp->virt, mp->phys); goto issue_mbox_fail; + } return 0; diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index ba17a8f740a95..7628b0634c57a 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -5373,8 +5373,10 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, */ if (!(phba->hba_flag & HBA_FCOE_MODE)) { rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) + if (rc == MBX_NOT_FINISHED) { + lpfc_mbuf_free(phba, mp->virt, mp->phys); goto out_free_dmabuf; + } return; } /* @@ -6337,8 +6339,10 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) } rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) + if (rc == MBX_NOT_FINISHED) { + lpfc_mbuf_free(phba, mp->virt, mp->phys); goto out_free_dmabuf; + } return; out_free_dmabuf: diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 27263f02ab9f6..7d717a4ac14d1 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -322,6 +322,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, { struct lpfc_hba *phba = vport->phba; struct lpfc_dmabuf *pcmd; + struct lpfc_dmabuf *mp; uint64_t nlp_portwwn = 0; uint32_t *lp; IOCB_t *icmd; @@ -571,6 +572,11 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, * a default RPI. */ if (phba->sli_rev == LPFC_SLI_REV4) { + mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf; + if (mp) { + lpfc_mbuf_free(phba, mp->virt, mp->phys); + kfree(mp); + } mempool_free(login_mbox, phba->mbox_mem_pool); login_mbox = NULL; } else { -- 2.34.1