Skip to content

Commit

Permalink
net: macb: add check for dma mapping error in start_xmit()
Browse files Browse the repository at this point in the history
at91ether_start_xmit() does not check for dma mapping errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
khoroshilov authored and davem330 committed Nov 19, 2016
1 parent f82ef3e commit 178c7ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/ethernet/cadence/macb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2673,6 +2673,12 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
lp->skb_length = skb->len;
lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len,
DMA_TO_DEVICE);
if (dma_mapping_error(NULL, lp->skb_physaddr)) {
dev_kfree_skb_any(skb);
dev->stats.tx_dropped++;
netdev_err(dev, "%s: DMA mapping error\n", __func__);
return NETDEV_TX_OK;
}

/* Set address of the data in the Transmit Address register */
macb_writel(lp, TAR, lp->skb_physaddr);
Expand Down

0 comments on commit 178c7ae

Please sign in to comment.