[PATCH net] net: qed: fix dead NULL check on the MPA buffer list

From: Ziheng Wei

Date: Sun Nov 15 2026 - 11:19:09 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Ziheng Wei <zihengw03@xxxxxxx>
---

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