12e531cab335246b4729d722a154e1ad092120be
[openwrt/staging/blogic.git] /
1 From 787082ab9f7be4711e52f67c388535eda74a1269 Mon Sep 17 00:00:00 2001
2 From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
3 Date: Thu, 22 Apr 2021 22:20:56 -0700
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: fix build_skb cleanup
5
6 In case build_skb fails, call skb_free_frag on the correct pointer. Also
7 update the DMA structures with the new mapping before exiting, because
8 the mapping was successful
9
10 Suggested-by: Felix Fietkau <nbd@nbd.name>
11 Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 +++--
15 1 file changed, 3 insertions(+), 2 deletions(-)
16
17 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 @@ -1339,9 +1339,9 @@ static int mtk_poll_rx(struct napi_struc
20 /* receive data */
21 skb = build_skb(data, ring->frag_size);
22 if (unlikely(!skb)) {
23 - skb_free_frag(new_data);
24 + skb_free_frag(data);
25 netdev->stats.rx_dropped++;
26 - goto release_desc;
27 + goto skip_rx;
28 }
29 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);
30
31 @@ -1361,6 +1361,7 @@ static int mtk_poll_rx(struct napi_struc
32 skb_record_rx_queue(skb, 0);
33 napi_gro_receive(napi, skb);
34
35 +skip_rx:
36 ring->data[idx] = new_data;
37 rxd->rxd1 = (unsigned int)dma_addr;
38