Skip to content

Commit

Permalink
net/mlx5e: TX, Use correct counter in dma_map error flow
Browse files Browse the repository at this point in the history
[ Upstream commit d9a96ec ]

In case of a dma_mapping_error, do not use wi->num_dma
as a parameter for dma unmap function because it's yet
to be set, and holds an out-of-date value.
Use actual value (local variable num_dma) instead.

Fixes: 34802a4 ("net/mlx5e: Do not modify the TX SKB")
Fixes: e586b3b ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Tariq Toukan <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Tariq Toukan authored and gregkh committed May 19, 2018
1 parent c3e7090 commit e48d6d7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ mlx5e_txwqe_build_dsegs(struct mlx5e_txqsq *sq, struct sk_buff *skb,
dma_addr = dma_map_single(sq->pdev, skb_data, headlen,
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(sq->pdev, dma_addr)))
return -ENOMEM;
goto dma_unmap_wqe_err;

dseg->addr = cpu_to_be64(dma_addr);
dseg->lkey = sq->mkey_be;
Expand All @@ -273,7 +273,7 @@ mlx5e_txwqe_build_dsegs(struct mlx5e_txqsq *sq, struct sk_buff *skb,
dma_addr = skb_frag_dma_map(sq->pdev, frag, 0, fsz,
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(sq->pdev, dma_addr)))
return -ENOMEM;
goto dma_unmap_wqe_err;

dseg->addr = cpu_to_be64(dma_addr);
dseg->lkey = sq->mkey_be;
Expand All @@ -285,6 +285,10 @@ mlx5e_txwqe_build_dsegs(struct mlx5e_txqsq *sq, struct sk_buff *skb,
}

return num_dma;

dma_unmap_wqe_err:
mlx5e_dma_unmap_wqe_err(sq, num_dma);
return -ENOMEM;
}

static inline void
Expand Down Expand Up @@ -380,17 +384,15 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
num_dma = mlx5e_txwqe_build_dsegs(sq, skb, skb_data, headlen,
(struct mlx5_wqe_data_seg *)cseg + ds_cnt);
if (unlikely(num_dma < 0))
goto dma_unmap_wqe_err;
goto err_drop;

mlx5e_txwqe_complete(sq, skb, opcode, ds_cnt + num_dma,
num_bytes, num_dma, wi, cseg);

return NETDEV_TX_OK;

dma_unmap_wqe_err:
err_drop:
sq->stats.dropped++;
mlx5e_dma_unmap_wqe_err(sq, wi->num_dma);

dev_kfree_skb_any(skb);

return NETDEV_TX_OK;
Expand Down Expand Up @@ -620,17 +622,15 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
num_dma = mlx5e_txwqe_build_dsegs(sq, skb, skb_data, headlen,
(struct mlx5_wqe_data_seg *)cseg + ds_cnt);
if (unlikely(num_dma < 0))
goto dma_unmap_wqe_err;
goto err_drop;

mlx5e_txwqe_complete(sq, skb, opcode, ds_cnt + num_dma,
num_bytes, num_dma, wi, cseg);

return NETDEV_TX_OK;

dma_unmap_wqe_err:
err_drop:
sq->stats.dropped++;
mlx5e_dma_unmap_wqe_err(sq, wi->num_dma);

dev_kfree_skb_any(skb);

return NETDEV_TX_OK;
Expand Down

0 comments on commit e48d6d7

Please sign in to comment.