* [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
* Re: [PATCH net] net: qed: fix dead NULL check on the MPA buffer list
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
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-16 16:21 UTC (permalink / raw)
To: zihengw03
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-kernel, stable
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message says nothing guarantees that mpa_buf_list
is non-empty, and that whether it can run empty "depends on traffic…
- [Low] The commit message says commit fbb8bc408027 ("net: qed: Remove
redundant NULL checks after list_first_entry()") "removed the other…
--
net: qed: fix dead NULL check on the MPA buffer list
This commit changes qed_iwarp_ll2_comp_mpa_pkt() to use
list_first_entry_or_null() instead of list_first_entry(). With that, the
existing "No free mpa buf" check on mpa_buf_list can actually fire. The
patch has a Fixes: tag for fcb39f6c10b2 and is Cc'd to stable.
> 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.
[Severity: Medium]
Can mpa_buf_list actually run empty here?
qed_iwarp_ll2_start() posts rx_num_desc RX buffers on the MPA LL2
connection. It then puts exactly rx_num_desc mpa_bufs on mpa_buf_list,
and the comment says this lookup is not supposed to fail:
drivers/net/ethernet/qlogic/qed/qed_iwarp.c:qed_iwarp_ll2_start() {
...
rc = qed_iwarp_ll2_alloc_buffers(p_hwfn,
data.input.rx_num_desc,
buff_size,
iwarp_info->ll2_mpa_handle);
...
/* The mpa_bufs array serves for pending RX packets received on the
* mpa ll2 that don't have place on the tx ring and require later
* processing. We can't fail on allocation of such a struct therefore
* we allocate enough to take care of all rx packets
*/
iwarp_info->mpa_bufs = kzalloc_objs(*iwarp_info->mpa_bufs,
data.input.rx_num_desc);
...
}
An mpa_buf only leaves the free list in qed_iwarp_ll2_comp_mpa_pkt(), and
only for an RX buffer that has just completed. It stays on the pending
list only while qed_iwarp_process_mpa_pkt() returns -EBUSY for it.
The -EBUSY paths are win_right_edge, cp_pkt/recycle_pkt and a send_fpdu
prepare failure. In each of them, that mpa_buf's own RX buffer has not
been reposted yet. cp_pkt recycles the previous buffer (fpdu->mpa_buf),
not the current one.
So every pending mpa_buf holds an RX buffer that has not been reposted.
When a new completion arrives, at most rx_num_desc - 1 mpa_bufs are in
use.
rx_num_desc sizes both pools. Doesn't that make the "No free mpa buf"
path unreachable, whatever the traffic or the value of rx_num_desc?
The only crash evidence in the changelog is a test module that empties
mpa_buf_list by hand. The list_first_entry_or_null() change looks like
harmless hardening. If no real path empties the list, do the Fixes: and
Cc: stable@vger.kernel.org tags still fit?
The changelog also treats the existing error path as a valid way to
handle an empty list. If that path ever ran, it would repost the RX
buffer and drop a TCP segment that firmware already sent to the
unaligned MPA path. Wouldn't that leave the connection's FPDU reassembly
state (incomplete_bytes and fpdu->mpa_buf) out of sync?
> 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().
[Severity: Low]
Is this an accurate description of fbb8bc408027? That commit only
changed three functions in qed_ooo.c: qed_ooo_release_connection_isles(),
qed_ooo_release_all_isles() and qed_ooo_free().
The same redundant pattern is still in other parts of qed: a NULL check
after list_first_entry() inside a !list_empty() guard. For example,
qed_ll2_txq_flush():
while (!list_empty(&p_tx->active_descq)) {
p_pkt = list_first_entry(&p_tx->active_descq,
struct qed_ll2_tx_packet, list_entry);
if (!p_pkt)
break;
There are similar checks in qed_ll2_txq_completion(), qed_ll2_rxq_flush(),
qed_ll2_tx_packet_notify() and qed_iwarp_free_prealloc_ep(). There are
more in qed_spq.c, qed_fcoe.c, qed_iscsi.c and qed_nvmetcp.c.
All of these are guarded, so none of them is a bug. Could the changelog
avoid saying that fbb8bc408027 removed all the other checks of this kind
in qed?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115161815.941090-1-zihengw03%40163.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: qed: fix dead NULL check on the MPA buffer list
2026-11-16 16:21 ` netdev-bot+sashiko
@ 2026-11-16 16:31 ` Ziheng Wei
0 siblings, 0 replies; 3+ messages in thread
From: Ziheng Wei @ 2026-11-16 16:31 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, linux-kernel, stable
On Mon, 16 Nov 2026 16:21:12 +0000, netdev-bot+sashiko@kernel.org wrote:
> rx_num_desc sizes both pools. Doesn't that make the "No free mpa buf"
> path unreachable, whatever the traffic or the value of rx_num_desc?
Yes, I agree. Every mpa_buf held on the pending list still owns an RX
buffer that has not been reposted, so a new completion can never find
mpa_buf_list empty. The "depends on traffic" sentence in the changelog
is wrong, and the only evidence was a test module that empties the
list by hand.
> If that path ever ran, it would repost the RX buffer and drop a TCP
> segment that firmware already sent to the unaligned MPA path.
Agreed as well, so making the error path reachable is not even an
obviously better behaviour than the current code.
> Is this an accurate description of fbb8bc408027?
No, it only touched qed_ooo.c. Sorry for the inaccurate description.
Please drop this patch. The Fixes: and stable tags do not fit, and I
don't think a hardening-only respin is worth it for an unreachable
path.
pw-bot: cr
^ permalink raw reply [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