aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <frediano.ziglio@huawei.com>2014-10-09 11:45:39 +0100
committerFrediano Ziglio <frediano.ziglio@huawei.com>2014-10-09 11:46:08 +0100
commitd0909cd184404d9a78e96225f69e109c1eafa256 (patch)
treeaa18e4cbc8fe848c71c5e31ecf4e578cd3f37440
parent55dac0371cd75c25063ba91cb12595927679b00b (diff)
ARM: hisi: fix wrong unmapping in hip04 eth driver
rx_phys array is initially initialized with zeroes. However it could be that in hip04_rx_poll addresses are still zero and we try to unmap them. For dma addresses 0 is considered perfectly fine so on some condition (for instance under Xen) the unmapping can cause a core. Signed-off-by: Frediano Ziglio <frediano.ziglio@huawei.com>
-rw-r--r--drivers/net/ethernet/hisilicon/hip04_eth.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index 7f01b910349e..7e2b8f38ba7e 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -420,9 +420,11 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
if (unlikely(!skb))
net_dbg_ratelimited("build_skb failed\n");
- dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head],
- RX_BUF_SIZE, DMA_FROM_DEVICE);
- priv->rx_phys[priv->rx_head] = 0;
+ if (priv->rx_phys[priv->rx_head]) {
+ dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head],
+ RX_BUF_SIZE, DMA_FROM_DEVICE);
+ priv->rx_phys[priv->rx_head] = 0;
+ }
desc = (struct rx_desc *)skb->data;
len = be16_to_cpu(desc->pkt_len);