diff mbox series

[v2] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling

Message ID 20210302100345.27982-2-biao.huang@mediatek.com (mailing list archive)
State New, archived
Headers show
Series [v2] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling | expand

Commit Message

Biao Huang (黄彪) March 2, 2021, 10:03 a.m. UTC
mtk_star_dma_unmap_rx() should unmap the dma_addr of old skb rather than
that of new skb.
Assign new_dma_addr to desc_data.dma_addr after all handling of old skb
ends to avoid unexpected receive side error.

Fixes: f96e9641e92b ("net: ethernet: mtk-star-emac: fix error path in RX handling")
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
 drivers/net/ethernet/mediatek/mtk_star_emac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
index a8641a407c06..84b3f56a9965 100644
--- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
+++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
@@ -1225,9 +1225,7 @@  static int mtk_star_receive_packet(struct mtk_star_priv *priv)
 		goto push_new_skb;
 	}
 
-	desc_data.dma_addr = new_dma_addr;
-
-	/* We can't fail anymore at this point: it's safe to unmap the skb. */
+	/* We can't fail anymore at this point: it's safe to unmap the old skb. */
 	mtk_star_dma_unmap_rx(priv, &desc_data);
 
 	skb_put(desc_data.skb, desc_data.len);
@@ -1236,6 +1234,9 @@  static int mtk_star_receive_packet(struct mtk_star_priv *priv)
 	desc_data.skb->dev = ndev;
 	netif_receive_skb(desc_data.skb);
 
+	/* update dma_addr for new skb */
+	desc_data.dma_addr = new_dma_addr;
+
 push_new_skb:
 	desc_data.len = skb_tailroom(new_skb);
 	desc_data.skb = new_skb;