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

STALE1978d

2 messages, 1 author, 2021-03-02 · open the first message on its own page

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

From: Biao Huang <hidden>
Date: 2021-03-02 10:22:05

V2:
    update the comment for unmapping the old skb

Biao Huang (1):
  net: ethernet: mtk-star-emac: fix wrong unmap in RX handling

 drivers/net/ethernet/mediatek/mtk_star_emac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--
2.25.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

From: Biao Huang <hidden>
Date: 2021-03-02 10:29:11

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 <redacted>
Signed-off-by: Biao Huang <redacted>
---
 drivers/net/ethernet/mediatek/mtk_star_emac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
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;
-- 
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help