610-v5.13-39-net-ethernet-mtk_eth_soc-fix-build_skb-cleanup.patch 1.3 KB

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