From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:09 +0000 (+0000) Subject: tg3: Fix stats while interface is down X-Git-Tag: v2.6.39-400.9.0~338^2~172 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e442f3310001a77901ad3318c64712fec172d856;p=users%2Fjedix%2Flinux-maple.git tg3: Fix stats while interface is down If the tg3 interface is down, the driver will return ethtool stats uninitialized. This patch zeroes out the destination stat buffer in such a case. (cherry picked from commit b546e46f5c9f19a921d6f62db80f2e9371bc0558) Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Joe Jin --- diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 454b3c5aea0f..1da1a05c2655 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -10160,9 +10160,6 @@ static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp, struct tg3_ethtool_stats *old_estats = &tp->estats_prev; struct tg3_hw_stats *hw_stats = tp->hw_stats; - if (!hw_stats) - return old_estats; - ESTAT_ADD(rx_octets); ESTAT_ADD(rx_fragments); ESTAT_ADD(rx_ucast_packets); @@ -11035,7 +11032,10 @@ static void tg3_get_ethtool_stats(struct net_device *dev, { struct tg3 *tp = netdev_priv(dev); - tg3_get_estats(tp, (struct tg3_ethtool_stats *)tmp_stats); + if (tp->hw_stats) + tg3_get_estats(tp, (struct tg3_ethtool_stats *)tmp_stats); + else + memset(tmp_stats, 0, sizeof(struct tg3_ethtool_stats)); } static __be32 *tg3_vpd_readblock(struct tg3 *tp, u32 *vpdlen)