Skip to content

Commit

Permalink
arc_emac: fix potential use after free
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Dumazet <edumazet@google.com>

skb_tx_timestamp(skb) should be called _before_ TX completion
has a chance to trigger, otherwise it is too late and we access
freed memory.

Fixes: e4f2379 ("ethernet/arc/arc_emac - Add new driver")
From: Eric Dumazet <edumazet@google.com>
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Dec 27, 2013
1 parent 3756791 commit 37ec274
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/arc/emac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
/* Make sure pointer to data buffer is set */
wmb();

skb_tx_timestamp(skb);

*info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | len);

/* Increment index to point to the next BD */
Expand All @@ -579,8 +581,6 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)

arc_reg_set(priv, R_STATUS, TXPL_MASK);

skb_tx_timestamp(skb);

return NETDEV_TX_OK;
}

Expand Down

0 comments on commit 37ec274

Please sign in to comment.