Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: qed: Remove redundant NULL checks after list_first_entry()

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>
Link: https://patch.msgid.link/20250924030219.1252773-1-zhen.ni@easystack.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Zhen Ni and committed by
Jakub Kicinski
fbb8bc40 347afa39

-9
-9
drivers/net/ethernet/qlogic/qed/qed_ooo.c
··· 183 183 struct qed_ooo_buffer, 184 184 list_entry); 185 185 186 - if (!p_buffer) 187 - break; 188 - 189 186 list_move_tail(&p_buffer->list_entry, 190 187 &p_ooo_info->free_buffers_list); 191 188 } ··· 214 217 list_first_entry(&p_isle->buffers_list, 215 218 struct qed_ooo_buffer, 216 219 list_entry); 217 - 218 - if (!p_buffer) 219 - break; 220 220 221 221 list_move_tail(&p_buffer->list_entry, 222 222 &p_ooo_info->free_buffers_list); ··· 248 254 while (!list_empty(&p_ooo_info->free_buffers_list)) { 249 255 p_buffer = list_first_entry(&p_ooo_info->free_buffers_list, 250 256 struct qed_ooo_buffer, list_entry); 251 - 252 - if (!p_buffer) 253 - break; 254 257 255 258 list_del(&p_buffer->list_entry); 256 259 dma_free_coherent(&p_hwfn->cdev->pdev->dev,