diff options
author | Michael Chan <mchan@broadcom.com> | 2012-07-29 15:15:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-30 02:18:31 -0400 |
commit | 0f566b208b41918053b2e67399673aaec02dde5d (patch) | |
tree | b07f2bcab010460c8a47272713abc95cc54395b8 /drivers/net/ethernet/broadcom/tg3.c | |
parent | 091f0ea30074bc43f9250961b3247af713024bc6 (diff) |
tg3: Fix race condition in tg3_get_stats64()
Spinlock should be taken before checking for tp->hw_stats.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/tg3.c')
-rw-r--r-- | drivers/net/ethernet/broadcom/tg3.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 50045ed1e8c0..f03614be9fd5 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -12524,10 +12524,12 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev, | |||
12524 | { | 12524 | { |
12525 | struct tg3 *tp = netdev_priv(dev); | 12525 | struct tg3 *tp = netdev_priv(dev); |
12526 | 12526 | ||
12527 | if (!tp->hw_stats) | 12527 | spin_lock_bh(&tp->lock); |
12528 | if (!tp->hw_stats) { | ||
12529 | spin_unlock_bh(&tp->lock); | ||
12528 | return &tp->net_stats_prev; | 12530 | return &tp->net_stats_prev; |
12531 | } | ||
12529 | 12532 | ||
12530 | spin_lock_bh(&tp->lock); | ||
12531 | tg3_get_nstats(tp, stats); | 12533 | tg3_get_nstats(tp, stats); |
12532 | spin_unlock_bh(&tp->lock); | 12534 | spin_unlock_bh(&tp->lock); |
12533 | 12535 | ||