提交 7ea6cd16 编写于 作者: A Aleksander Jan Bajkowski 提交者: David S. Miller

lantiq: net: fix duplicated skb in rx descriptor ring

The previous commit didn't fix the bug properly. By mistake, it replaces
the pointer of the next skb in the descriptor ring instead of the current
one. As a result, the two descriptors are assigned the same SKB. The error
is seen during the iperf test when skb_put tries to insert a second packet
and exceeds the available buffer.

Fixes: c7718ee9 ("net: lantiq: fix memory corruption in RX ring ")
Signed-off-by: NAleksander Jan Bajkowski <olek2@wp.pl>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 057d4933
...@@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev) ...@@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev)
static int xrx200_alloc_skb(struct xrx200_chan *ch) static int xrx200_alloc_skb(struct xrx200_chan *ch)
{ {
struct sk_buff *skb = ch->skb[ch->dma.desc];
dma_addr_t mapping; dma_addr_t mapping;
int ret = 0; int ret = 0;
...@@ -168,6 +169,7 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch) ...@@ -168,6 +169,7 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch)
XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE); XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE);
if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) { if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) {
dev_kfree_skb_any(ch->skb[ch->dma.desc]); dev_kfree_skb_any(ch->skb[ch->dma.desc]);
ch->skb[ch->dma.desc] = skb;
ret = -ENOMEM; ret = -ENOMEM;
goto skip; goto skip;
} }
...@@ -198,7 +200,6 @@ static int xrx200_hw_receive(struct xrx200_chan *ch) ...@@ -198,7 +200,6 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
ch->dma.desc %= LTQ_DESC_NUM; ch->dma.desc %= LTQ_DESC_NUM;
if (ret) { if (ret) {
ch->skb[ch->dma.desc] = skb;
net_dev->stats.rx_dropped++; net_dev->stats.rx_dropped++;
netdev_err(net_dev, "failed to allocate new rx buffer\n"); netdev_err(net_dev, "failed to allocate new rx buffer\n");
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册