Message ID | 20210302033323.25830-1-biao.huang@mediatek.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: ethernet: mtk-star-emac: fix wrong unmap in RX handling | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/cc_maintainers | success | CCed 11 of 11 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 17 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Tue, Mar 2, 2021 at 4:33 AM Biao Huang <biao.huang@mediatek.com> wrote: > > 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") > Signed-off-by: Biao Huang <biao.huang@mediatek.com> > --- > drivers/net/ethernet/mediatek/mtk_star_emac.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c > index a8641a407c06..96d2891f1675 100644 > --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > @@ -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); > > @@ -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 > Thanks for spotting that. Maybe also update the commit so that it says: "it's safe to unmap the old skb"? Would make the thing clearer IMO. In any case: Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Bartosz
diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index a8641a407c06..96d2891f1675 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -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); @@ -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;
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") Signed-off-by: Biao Huang <biao.huang@mediatek.com> --- drivers/net/ethernet/mediatek/mtk_star_emac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)