Skip to content

Commit 7ea6cd1

Browse files
abajkdavem330
authored andcommitted
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: c7718ee ("net: lantiq: fix memory corruption in RX ring ") Signed-off-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 057d493 commit 7ea6cd1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/lantiq_xrx200.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev)
154154

155155
static int xrx200_alloc_skb(struct xrx200_chan *ch)
156156
{
157+
struct sk_buff *skb = ch->skb[ch->dma.desc];
157158
dma_addr_t mapping;
158159
int ret = 0;
159160

@@ -168,6 +169,7 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch)
168169
XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE);
169170
if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) {
170171
dev_kfree_skb_any(ch->skb[ch->dma.desc]);
172+
ch->skb[ch->dma.desc] = skb;
171173
ret = -ENOMEM;
172174
goto skip;
173175
}
@@ -198,7 +200,6 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
198200
ch->dma.desc %= LTQ_DESC_NUM;
199201

200202
if (ret) {
201-
ch->skb[ch->dma.desc] = skb;
202203
net_dev->stats.rx_dropped++;
203204
netdev_err(net_dev, "failed to allocate new rx buffer\n");
204205
return ret;

0 commit comments

Comments
 (0)