netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v2 PATCH 0/1] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling
@ 2021-03-02 10:03 Biao Huang
  2021-03-02 10:03 ` [v2 PATCH] " Biao Huang
  0 siblings, 1 reply; 2+ messages in thread
From: Biao Huang @ 2021-03-02 10:03 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Felix Fietkau, John Crispin, Sean Wang, Mark Lee,
	David S . Miller, Jakub Kicinski, Matthias Brugger, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel, biao.huang,
	srv_heupstream

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [v2 PATCH] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling
  2021-03-02 10:03 [v2 PATCH 0/1] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling Biao Huang
@ 2021-03-02 10:03 ` Biao Huang
  0 siblings, 0 replies; 2+ messages in thread
From: Biao Huang @ 2021-03-02 10:03 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Felix Fietkau, John Crispin, Sean Wang, Mark Lee,
	David S . Miller, Jakub Kicinski, Matthias Brugger, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel, biao.huang,
	srv_heupstream

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 --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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-02 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 10:03 [v2 PATCH 0/1] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling Biao Huang
2021-03-02 10:03 ` [v2 PATCH] " Biao Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).