From patchwork Wed Jan 17 23:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13522255 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECEEF286B8 for ; Wed, 17 Jan 2024 23:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705535131; cv=none; b=le8ZS1+lwsHutOD5xYJEXsLIlHIdzY5+1gG1oXhhazvJgVIIlW6rVtLXkciuVDC+3MbJsPrhp6CYOGkcArtYKQuuzuXMKNef1krypAiYSnsOd4vA09bzLhi5kZElSLzU4nWn2eo+GN5pK+nxMNrdGWjFFIDvu4qp+P6430qw8lU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705535131; c=relaxed/simple; bh=tb9zeqBD6k4CMRXsHUEAz92V8bbNsTdAKZWkGqgZYpg=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:From: To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type; b=fRy+mzPaRF1c0cn/mA0jJdyhuurZQnf/34xvtyXv9uzkWgXB6nlib/QNfr1ZxikgRT4jpXR2hSeos366L6gQnlBQkJFMideF7GuDlgqJwrgbmDB25ru8m0ja+JEbASbWV8DlOrOBRTwo5ZkI/gIp+/Lge89AqVsxOQRx/BLZq+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=DKjW6Auy; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="DKjW6Auy" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7831aacdaffso1103490585a.3 for ; Wed, 17 Jan 2024 15:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1705535129; x=1706139929; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=DkhjtwraQeMSB3nHUy32LqXxk839eLPrEHDv2Fa3mz8=; b=DKjW6AuyClEusrouWeDAr+hxsNInuNVFM4/iWrmN//ziCRZKfKLFpHjh2bMqnarJp8 RoRvkx0dLRcT0w1P5R3/6svgZEvCmDid1MCiQaEnx+pElhdb+5sSp1TfZ6UB28OMPWl/ CrWsXlD/RZ6Z8tDXL4JvIft+uz8TN3agZwuco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705535129; x=1706139929; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DkhjtwraQeMSB3nHUy32LqXxk839eLPrEHDv2Fa3mz8=; b=YLSUiYSvbjUbCSzmjsguMrYdeIvxCKXWXcPABJbzkaXG3z+04eSIHsm0m7DY19+6HI J4wnicBzWORgM37eIx6WbBRisR9A1Js1GmNAxW5xVFiu+FQl8OYHlWfu4yXVnw93B+q0 pBI6W59UAZXJK8WjWXXcH6nHWAqfCAKKgo5J0Q5Xr41TQQKhrOBAmdig7MP6ke2EqNnm QLIEBI49zfr8sVVZvolsJEX7y2/n/XIt9bq3oFs//yxQK5eKHqvkpzemTDPVWAZG6JBV Een4TodFUwkmvFNZ/Xe9TlFQSqVEdv6yVQVRiplWBmNRRjYlU75uZpJSHIbTW/AVJH93 R/yQ== X-Gm-Message-State: AOJu0YxpqLsYQ5pZ/GMF344acOhboEGR1b1gcZS/OlQZ8O05SyViSwn9 +/Gx0pCd7KM8rXH0DPTsBztXd2VWmE28negH08d75V0viQ== X-Google-Smtp-Source: AGHT+IE79/rmMWQbSPkRRz8Pi5I4IrpQRPq9vbcbuKVeE9RIujMuYvglmHRI6bEKsnU0moZWydbPGg== X-Received: by 2002:a05:620a:4551:b0:783:3423:c76d with SMTP id u17-20020a05620a455100b007833423c76dmr12619757qkp.1.1705535128783; Wed, 17 Jan 2024 15:45:28 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id b8-20020a05620a126800b0077d78c5b575sm4851105qkl.111.2024.01.17.15.45.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2024 15:45:28 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, Somnath Kotur Subject: [PATCH net 2/5] bnxt_en: Fix memory leak in bnxt_hwrm_get_rings() Date: Wed, 17 Jan 2024 15:45:12 -0800 Message-Id: <20240117234515.226944-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240117234515.226944-1-michael.chan@broadcom.com> References: <20240117234515.226944-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org bnxt_hwrm_get_rings() can abort and return error when there are not enough ring resources. It aborts without releasing the HWRM DMA buffer, causing a dma_pool_destroy warning when the driver is unloaded: bnxt_en 0000:99:00.0: dma_pool_destroy bnxt_hwrm, 000000005b089ba8 busy Fixes: f1e50b276d37 ("bnxt_en: Fix trimming of P5 RX and TX rings") Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0866aba35d9b..9fdc90bfce38 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6926,7 +6926,7 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp) if (cp < (rx + tx)) { rc = __bnxt_trim_rings(bp, &rx, &tx, cp, false); if (rc) - return rc; + goto get_rings_exit; if (bp->flags & BNXT_FLAG_AGG_RINGS) rx <<= 1; hw_resc->resv_rx_rings = rx; @@ -6938,8 +6938,9 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp) hw_resc->resv_cp_rings = cp; hw_resc->resv_stat_ctxs = stats; } +get_rings_exit: hwrm_req_drop(bp, req); - return 0; + return rc; } int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings)