Commit 2ad8e573 authored by Michael Chan's avatar Michael Chan Committed by Jakub Kicinski

bnxt_en: Fix memory leak in bnxt_hwrm_get_rings()

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: f1e50b27 ("bnxt_en: Fix trimming of P5 RX and TX rings")
Reviewed-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20240117234515.226944-3-michael.chan@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3c1069fa
...@@ -6926,7 +6926,7 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp) ...@@ -6926,7 +6926,7 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp)
if (cp < (rx + tx)) { if (cp < (rx + tx)) {
rc = __bnxt_trim_rings(bp, &rx, &tx, cp, false); rc = __bnxt_trim_rings(bp, &rx, &tx, cp, false);
if (rc) if (rc)
return rc; goto get_rings_exit;
if (bp->flags & BNXT_FLAG_AGG_RINGS) if (bp->flags & BNXT_FLAG_AGG_RINGS)
rx <<= 1; rx <<= 1;
hw_resc->resv_rx_rings = rx; hw_resc->resv_rx_rings = rx;
...@@ -6938,8 +6938,9 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp) ...@@ -6938,8 +6938,9 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp)
hw_resc->resv_cp_rings = cp; hw_resc->resv_cp_rings = cp;
hw_resc->resv_stat_ctxs = stats; hw_resc->resv_stat_ctxs = stats;
} }
get_rings_exit:
hwrm_req_drop(bp, req); hwrm_req_drop(bp, req);
return 0; return rc;
} }
int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings) int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment