Skip to content

Commit

Permalink
net: ethernet: mtk-star-emac: fix error path in RX handling
Browse files Browse the repository at this point in the history
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: 8c7bd5a ("net: ethernet: mtk-star-emac: new driver")
Reported-by: Nathan Chancellor <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
Tested-by: Nathan Chancellor <[email protected]> # build
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
brgl authored and davem330 committed May 27, 2020
1 parent 7cf4eda commit f96e964
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mediatek/mtk_star_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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

Expand Down

0 comments on commit f96e964

Please sign in to comment.