Skip to content

Commit 8ed2fa6

Browse files
MeghanaMalladiTIPaolo Abeni
authored andcommitted
net: ti: icssg-prueth: Fix possible NULL pointer dereference inside emac_xmit_xdp_frame()
There is an error check inside emac_xmit_xdp_frame() function which is called when the driver wants to transmit XDP frame, to check if the allocated tx descriptor is NULL, if true to exit and return ICSSG_XDP_CONSUMED implying failure in transmission. In this case trying to free a descriptor which is NULL will result in kernel crash due to NULL pointer dereference. Fix this error handling and increase netdev tx_dropped stats in the caller of this function if the function returns ICSSG_XDP_CONSUMED. Fixes: 62aa324 ("net: ti: icssg-prueth: Add XDP support") Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Meghana Malladi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Roger Quadros <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 75bc744 commit 8ed2fa6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/ti/icssg/icssg_common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,
583583
first_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool);
584584
if (!first_desc) {
585585
netdev_dbg(ndev, "xdp tx: failed to allocate descriptor\n");
586-
goto drop_free_descs; /* drop */
586+
return ICSSG_XDP_CONSUMED; /* drop */
587587
}
588588

589589
if (page) { /* already DMA mapped by page_pool */
@@ -671,8 +671,10 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
671671

672672
q_idx = smp_processor_id() % emac->tx_ch_num;
673673
result = emac_xmit_xdp_frame(emac, xdpf, page, q_idx);
674-
if (result == ICSSG_XDP_CONSUMED)
674+
if (result == ICSSG_XDP_CONSUMED) {
675+
ndev->stats.tx_dropped++;
675676
goto drop;
677+
}
676678

677679
dev_sw_netstats_rx_add(ndev, xdpf->len);
678680
return result;

0 commit comments

Comments
 (0)