Skip to content

Commit

Permalink
net: ethernet: mtk-star-emac: fix wrong unmap in RX handling
Browse files Browse the repository at this point in the history
commit 95b39f0 upstream.

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: f96e964 ("net: ethernet: mtk-star-emac: fix error path in RX handling")
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Biao Huang authored and gregkh committed Mar 17, 2021
1 parent 10ec8fe commit e4abfed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mediatek/mtk_star_emac.c
Expand Up @@ -1225,8 +1225,6 @@ 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. */
mtk_star_dma_unmap_rx(priv, &desc_data);

Expand All @@ -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;
Expand Down

0 comments on commit e4abfed

Please sign in to comment.