From: Michael Chan Date: Sun, 29 Jul 2012 19:15:44 +0000 (+0000) Subject: tg3: Fix race condition in tg3_get_stats64() X-Git-Tag: MMI-PSA29.97-13-9~16207^2~11 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0f566b208b41918053b2e67399673aaec02dde5d;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git tg3: Fix race condition in tg3_get_stats64() Spinlock should be taken before checking for tp->hw_stats. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- 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, { 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);