From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch,
pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com,
Shruti Parab <shruti.parab@broadcom.com>,
Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Subject: [PATCH net 6/8] bnxt_en: Fix coredump logic to free allocated buffer
Date: Mon, 28 Apr 2025 15:59:01 -0700 [thread overview]
Message-ID: <20250428225903.1867675-7-michael.chan@broadcom.com> (raw)
In-Reply-To: <20250428225903.1867675-1-michael.chan@broadcom.com>
From: Shruti Parab <shruti.parab@broadcom.com>
When handling HWRM_DBG_COREDUMP_LIST FW command in
bnxt_hwrm_dbg_dma_data(), the allocated buffer info->dest_buf is
not freed in the error path. In the normal path, info->dest_buf
is assigned to coredump->data and it will eventually be freed after
the coredump is collected.
Free info->dest_buf immediately inside bnxt_hwrm_dbg_dma_data() in
the error path.
Fixes: c74751f4c392 ("bnxt_en: Return error if FW returns more data than dump length")
Reported-by: Michael Chan <michael.chan@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Shruti Parab <shruti.parab@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
index 5576e7cf8463..9a74793648f6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
@@ -116,6 +116,11 @@ static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
memcpy(info->dest_buf + off, dma_buf, len);
} else {
rc = -ENOBUFS;
+ if (cmn_req->req_type ==
+ cpu_to_le16(HWRM_DBG_COREDUMP_LIST)) {
+ kfree(info->dest_buf);
+ info->dest_buf = NULL;
+ }
break;
}
}
--
2.30.1
next prev parent reply other threads:[~2025-04-28 22:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 22:58 [PATCH net 0/8] bnxt_en: Misc. bug fixes Michael Chan
2025-04-28 22:58 ` [PATCH net 1/8] bnxt_en: Fix error handling path in bnxt_init_chip() Michael Chan
2025-04-28 22:58 ` [PATCH net 2/8] bnxt_en: Fix ethtool selftest output in one of the failure cases Michael Chan
2025-04-28 22:58 ` [PATCH net 3/8] bnxt_en: Add missing skb_mark_for_recycle() in bnxt_rx_vlan() Michael Chan
2025-04-28 22:58 ` [PATCH net 4/8] bnxt_en: call pci_alloc_irq_vectors() after bnxt_reserve_rings() Michael Chan
2025-04-28 22:59 ` [PATCH net 5/8] bnxt_en: delay pci_alloc_irq_vectors() in the AER path Michael Chan
2025-04-28 22:59 ` Michael Chan [this message]
2025-04-28 22:59 ` [PATCH net 7/8] bnxt_en: Fix out-of-bound memcpy() during ethtool -w Michael Chan
2025-04-28 22:59 ` [PATCH net 8/8] bnxt_en: Fix ethtool -d byte order for 32-bit values Michael Chan
2025-05-01 13:57 ` [PATCH net 0/8] bnxt_en: Misc. bug fixes Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250428225903.1867675-7-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=shruti.parab@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).