From: Bartosz Golaszewski Date: Wed, 27 May 2020 09:24:04 +0000 (+0200) Subject: net: ethernet: mtk-star-emac: fix error path in RX handling X-Git-Tag: baikal/mips/sdk5.9~13530^2~90 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=ef58246290a2449af53fceec037725d54e59ff52;p=kernel.git net: ethernet: mtk-star-emac: fix error path in RX handling The dma_addr field in desc_data must not be overwritten until after the new skb is mapped. Currently we do replace it with uninitialized value in error path. This change fixes it by moving the assignment before the label to which we jump after mapping or allocation errors. Fixes: 8c62308a9f55 ("net: ethernet: mtk-star-emac: new driver") Reported-by: Nathan Chancellor Signed-off-by: Bartosz Golaszewski Tested-by: Nathan Chancellor # build Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index b74349cede28f..72bb624a6a68a 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -1308,6 +1308,8 @@ 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); @@ -1318,7 +1320,6 @@ static int mtk_star_receive_packet(struct mtk_star_priv *priv) netif_receive_skb(desc_data.skb); push_new_skb: - desc_data.dma_addr = new_dma_addr; desc_data.len = skb_tailroom(new_skb); desc_data.skb = new_skb;