[PATCH net v4 0/2] octeon_ep: Add SKB allocation failures handling in __octep_oq_process_rx()

From: Aleksandr Mishin
Date: Sat Oct 12 2024 - 06:01:50 EST


__octep_oq_process_rx() is called during NAPI polling by the driver and
calls build_skb() which may return NULL as skb pointer in case of memory
allocation error. This pointer is dereferenced later without checking for
NULL.

In this series, we introduce two helpers to make the fix more readable and
avoid code duplication. Also we handle build_skb() errors inside
__octep_oq_process_rx() to avoid NULL pointer dereference.

A similar situation is present in the __octep_vf_oq_process_rx() of the
Octeon VF driver. First we want to try the fix on __octep_oq_process_rx().

Compile tested only.

Changelog:
v4:
- Split patch up as suggested by Jakub
(https://lore.kernel.org/all/20241004073311.223efca4@xxxxxxxxxx/)
v3: https://lore.kernel.org/all/20240930053328.9618-1-amishin@xxxxxxxxxx/
- Implement helper which frees current packet resources and increase
index and descriptor as suggested by Simon
(https://lore.kernel.org/all/20240919134812.GB1571683@xxxxxxxxxx/)
- Optimize helper as suggested by Paolo
(https://lore.kernel.org/all/b9ae8575-f903-425f-aa42-0c2a7605aa94@xxxxxxxxxx/)
- v3 has been reviewed-by Simon Horman
(https://lore.kernel.org/all/20240930162622.GF1310185@xxxxxxxxxx/)
v2: https://lore.kernel.org/all/20240916060212.12393-1-amishin@xxxxxxxxxx/
- Implement helper instead of adding multiple checks for '!skb' and
remove 'rx_bytes' increasing in case of packet dropping as suggested
by Paolo
(https://lore.kernel.org/all/ba514498-3706-413b-a09f-f577861eef28@xxxxxxxxxx/)
v1: https://lore.kernel.org/all/20240906063907.9591-1-amishin@xxxxxxxxxx/

Aleksandr Mishin (2):
octeon_ep: Implement helper for iterating packets in Rx queue
octeon_ep: Add SKB allocation failures handling in
__octep_oq_process_rx()

.../net/ethernet/marvell/octeon_ep/octep_rx.c | 82 +++++++++++++------
1 file changed, 59 insertions(+), 23 deletions(-)

--
2.30.2