Skip to content

Commit a6099f2

Browse files
nmenonPaolo Abeni
authored andcommitted
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: 9a369ae ("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>
1 parent e27e34b commit a6099f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
15221522
}
15231523
}
15241524

1525-
if (single_port) {
1525+
if (single_port && num_tx) {
15261526
netif_txq = netdev_get_tx_queue(ndev, chn);
15271527
netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
15281528
am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);

0 commit comments

Comments
 (0)