net: ethernet: ti: am65-cpsw-nuss: Fix null pointer dereference for ndev
authorNishanth Menon <nm@ti.com>
Fri, 29 Aug 2025 12:10:51 +0000 (17:40 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 2 Sep 2025 12:51:45 +0000 (14:51 +0200)
commita6099f263e1f408bcc7913c9df24b0677164fc5d
treee9ff200e7c593c345ca8d78284f6d263d93b03ab
parente27e34bc99413a29cafae02ad572ea3c9beba2ce
net: ethernet: ti: am65-cpsw-nuss: Fix null pointer dereference for ndev

In the TX completion packet stage of TI SoCs with CPSW2G instance, which
has single external ethernet port, ndev is accessed without being
initialized if no TX packets have been processed. It results into null
pointer dereference, causing kernel to crash. Fix this by having a check
on the number of TX packets which have been processed.

Fixes: 9a369ae3d143 ("net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g()")
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Chintan Vankar <c-vankar@ti.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250829121051.2031832-1-c-vankar@ti.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/ti/am65-cpsw-nuss.c