Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: qed: fix dead NULL check on the MPA buffer list
@ 2026-11-15 16:18 Ziheng Wei
  2026-11-16 16:21 ` netdev-bot+sashiko
  0 siblings, 1 reply; 3+ messages in thread
From: Ziheng Wei @ 2026-11-15 16:18 UTC (permalink / raw)
  To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: netdev, linux-kernel, stable

qed_iwarp_ll2_comp_mpa_pkt() takes a buffer from mpa_buf_list with
list_first_entry() and then checks the result for NULL. list_first_entry()
never returns NULL: on an empty list it returns a pointer computed from
the list head, so the "No free mpa buf" error path is dead and the list
head is used as a struct qed_iwarp_ll2_mpa_buf.

Buffers taken here go back to mpa_buf_list only through
qed_iwarp_process_pending_pkts(), which keeps a buffer on the pending
list while an FPDU is split across packets (-EBUSY). Whether the list
can run empty in practice depends on traffic and rx_num_desc; the driver
already has an error path for it, which just never runs.

Commit fbb8bc408027 ("net: qed: Remove redundant NULL checks after
list_first_entry()") removed the other checks of this kind in qed where
the list was known to be non-empty. Nothing guarantees that here, so
keep the check and make it effective with list_first_entry_or_null().

Found by LLM-assisted source review. Validated only with a test module
that calls the function with an empty mpa_buf_list, which oopses in
__list_add_valid_or_report(). The fix was build tested only; it was not
run against that module, selftests or hardware.

Fixes: fcb39f6c10b2 ("qed: Add mpa buffer descriptors for storing and processing mpa fpdus")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
---

Notes:
    The changelog was drafted with an AI assistant from my analysis;
    I have reviewed the code, the fix and the text.

 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index 4d1ce9b1a..057d6c0bd 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -2314,8 +2314,8 @@ qed_iwarp_ll2_comp_mpa_pkt(void *cxt, struct qed_ll2_comp_rx_data *data)
 	u16 first_mpa_offset;
 
 	iwarp_info = &p_hwfn->p_rdma_info->iwarp;
-	mpa_buf = list_first_entry(&iwarp_info->mpa_buf_list,
-				   struct qed_iwarp_ll2_mpa_buf, list_entry);
+	mpa_buf = list_first_entry_or_null(&iwarp_info->mpa_buf_list,
+					   struct qed_iwarp_ll2_mpa_buf, list_entry);
 	if (!mpa_buf) {
 		DP_ERR(p_hwfn, "No free mpa buf\n");
 		goto err;

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-15 16:18 [PATCH net] net: qed: fix dead NULL check on the MPA buffer list Ziheng Wei
2026-11-16 16:21 ` netdev-bot+sashiko
2026-11-16 16:31   ` Ziheng Wei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox