summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <brouer@redhat.com>2018-07-30 19:49:08 +0200
committerDavid S. Miller <davem@davemloft.net>2018-07-31 18:44:41 +0200
commit39c64d8c876622e766dd2112baf81151dd82da02 (patch)
treeb1bb7579587bf14e0199b644c535a70f52ded8e2 /drivers
parenthv_netvsc: Add per-cpu ethtool stats for netvsc (diff)
downloadlinux-39c64d8c876622e766dd2112baf81151dd82da02.tar.xz
linux-39c64d8c876622e766dd2112baf81151dd82da02.zip
mlx5: handle DMA mapping error case for XDP redirect
Commit 58b99ee3e3eb ("net/mlx5e: Add support for XDP_REDIRECT in device-out side") forgot to return/free the xdp_frame in case the DMA mapping failed, correct this. Also DMA unmap the frame in case mlx5e_xmit_xdp_frame() fails. Fixes: 58b99ee3e3eb ("net/mlx5e: Add support for XDP_REDIRECT in device-out side") Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Reviewed-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
index bab8cd44d1c5..1881468dbcfa 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
@@ -283,6 +283,7 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
xdpi.dma_addr = dma_map_single(sq->pdev, xdpf->data, xdpf->len,
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(sq->pdev, xdpi.dma_addr))) {
+ xdp_return_frame_rx_napi(xdpf);
drops++;
continue;
}
@@ -290,6 +291,8 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
xdpi.xdpf = xdpf;
if (unlikely(!mlx5e_xmit_xdp_frame(sq, &xdpi))) {
+ dma_unmap_single(sq->pdev, xdpi.dma_addr,
+ xdpf->len, DMA_TO_DEVICE);
xdp_return_frame_rx_napi(xdpf);
drops++;
}