* [PATCH] net: qed: Remove redundant NULL checks after list_first_entry()
@ 2025-09-24 3:02 Zhen Ni
2025-09-26 23:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Zhen Ni @ 2025-09-24 3:02 UTC (permalink / raw)
To: manishc, andrew+netdev, davem, edumazet, kuba, pabeni; +Cc: netdev, Zhen Ni
list_first_entry() never returns NULL — if the list is empty, it still
returns a pointer to an invalid object, leading to potential invalid
memory access when dereferenced.
The calls to list_first_entry() are always guarded by !list_empty(),
which guarantees a valid entry is returned. Therefore, the additional
`if (!p_buffer) break;` checks in qed_ooo_release_connection_isles(),
qed_ooo_release_all_isles(), and qed_ooo_free() are redundant and
unreachable.
Remove the dead code for clarity and consistency with common list
handling patterns in the kernel. No functional change intended.
Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
---
drivers/net/ethernet/qlogic/qed/qed_ooo.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ooo.c b/drivers/net/ethernet/qlogic/qed/qed_ooo.c
index 5d725f59db24..8be567a6ad44 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ooo.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ooo.c
@@ -183,9 +183,6 @@ void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
struct qed_ooo_buffer,
list_entry);
- if (!p_buffer)
- break;
-
list_move_tail(&p_buffer->list_entry,
&p_ooo_info->free_buffers_list);
}
@@ -218,9 +215,6 @@ void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
struct qed_ooo_buffer,
list_entry);
- if (!p_buffer)
- break;
-
list_move_tail(&p_buffer->list_entry,
&p_ooo_info->free_buffers_list);
}
@@ -255,9 +249,6 @@ void qed_ooo_free(struct qed_hwfn *p_hwfn)
p_buffer = list_first_entry(&p_ooo_info->free_buffers_list,
struct qed_ooo_buffer, list_entry);
- if (!p_buffer)
- break;
-
list_del(&p_buffer->list_entry);
dma_free_coherent(&p_hwfn->cdev->pdev->dev,
p_buffer->rx_buffer_size,
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: qed: Remove redundant NULL checks after list_first_entry()
2025-09-24 3:02 [PATCH] net: qed: Remove redundant NULL checks after list_first_entry() Zhen Ni
@ 2025-09-26 23:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-26 23:50 UTC (permalink / raw)
To: Zhen Ni; +Cc: manishc, andrew+netdev, davem, edumazet, kuba, pabeni, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 24 Sep 2025 11:02:19 +0800 you wrote:
> list_first_entry() never returns NULL — if the list is empty, it still
> returns a pointer to an invalid object, leading to potential invalid
> memory access when dereferenced.
> The calls to list_first_entry() are always guarded by !list_empty(),
> which guarantees a valid entry is returned. Therefore, the additional
> `if (!p_buffer) break;` checks in qed_ooo_release_connection_isles(),
> qed_ooo_release_all_isles(), and qed_ooo_free() are redundant and
> unreachable.
>
> [...]
Here is the summary with links:
- net: qed: Remove redundant NULL checks after list_first_entry()
https://git.kernel.org/netdev/net-next/c/fbb8bc408027
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-26 23:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 3:02 [PATCH] net: qed: Remove redundant NULL checks after list_first_entry() Zhen Ni
2025-09-26 23:50 ` patchwork-bot+netdevbpf
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).