summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2012-07-29 19:15:44 +0000
committerDavid S. Miller <davem@davemloft.net>2012-07-29 23:18:31 -0700
commit0f566b208b41918053b2e67399673aaec02dde5d (patch)
treeb07f2bcab010460c8a47272713abc95cc54395b8 /drivers/net
parent091f0ea30074bc43f9250961b3247af713024bc6 (diff)
downloadlinux-3.10-0f566b208b41918053b2e67399673aaec02dde5d.tar.gz
linux-3.10-0f566b208b41918053b2e67399673aaec02dde5d.tar.bz2
linux-3.10-0f566b208b41918053b2e67399673aaec02dde5d.zip
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')
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 50045ed1e8c..f03614be9fd 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,
{
struct tg3 *tp = netdev_priv(dev);
- if (!tp->hw_stats)
+ spin_lock_bh(&tp->lock);
+ if (!tp->hw_stats) {
+ spin_unlock_bh(&tp->lock);
return &tp->net_stats_prev;
+ }
- spin_lock_bh(&tp->lock);
tg3_get_nstats(tp, stats);
spin_unlock_bh(&tp->lock);