]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 17:02:23 +0000 (19:02 +0200)
[ Upstream commit a6099f263e1f408bcc7913c9df24b0677164fc5d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/ti/am65-cpsw-nuss.c

index 231ca141331f5188313c50b387080d9e138c5b0a..dbdbc40109c51db083efdd984a4f19e936d6179c 100644 (file)
@@ -1522,7 +1522,7 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
                }
        }
 
-       if (single_port) {
+       if (single_port && num_tx) {
                netif_txq = netdev_get_tx_queue(ndev, chn);
                netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
                am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);