Skip to content

Commit 0a50c35

Browse files
rogerqPaolo Abeni
authored andcommitted
net: ethernet: ti: am65-cpsw: Fix NULL dereference on XDP_TX
If number of TX queues are set to 1 we get a NULL pointer dereference during XDP_TX. ~# ethtool -L eth0 tx 1 ~# ./xdp-trafficgen udp -A <ipv6-src> -a <ipv6-dst> eth0 -t 2 Transmitting on eth0 (ifindex 2) [ 241.135257] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000030 Fix this by using actual TX queues instead of max TX queues when picking the TX channel in am65_cpsw_ndo_xdp_xmit(). Fixes: 8acacc4 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support") Signed-off-by: Roger Quadros <rogerq@kernel.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Acked-by: Julien Panis <jpanis@baylibre.com> Reviewed-by: MD Danish Anwar <danishanwar@ti.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 5e24db5 commit 0a50c35

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,12 +1924,13 @@ static int am65_cpsw_ndo_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
19241924
static int am65_cpsw_ndo_xdp_xmit(struct net_device *ndev, int n,
19251925
struct xdp_frame **frames, u32 flags)
19261926
{
1927+
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
19271928
struct am65_cpsw_tx_chn *tx_chn;
19281929
struct netdev_queue *netif_txq;
19291930
int cpu = smp_processor_id();
19301931
int i, nxmit = 0;
19311932

1932-
tx_chn = &am65_ndev_to_common(ndev)->tx_chns[cpu % AM65_CPSW_MAX_TX_QUEUES];
1933+
tx_chn = &common->tx_chns[cpu % common->tx_ch_num];
19331934
netif_txq = netdev_get_tx_queue(ndev, tx_chn->id);
19341935

19351936
__netif_tx_lock(netif_txq, cpu);

0 commit comments

Comments
 (0)