[PATCH] tg3: netif_carrier_off runs too early; could still be queued when init fails

From: Jeff Mahoney
Date: Mon Feb 20 2006 - 14:41:29 EST


This patch moves the netif_carrier_off() call from tg3_init_one()->
tg3_init_link_config() to tg3_open() as is the convention for most
other network drivers.

I was getting a panic after a tg3 device failed to initialize due to DMA
failure. The oops pointed to the link watch queue with spinlock debugging
enabled. Without spinlock debugging, the Oops didn't occur.

I suspect that the link event was getting queued but not executed until
after the DMA test had failed and the device was freed. The link event
was then operating on freed memory, which could contain anything. With this
patch applied, the Oops no longer occurs.

I believe this to be correct, but since I'm not a network guru, perhaps
someone who is could comment?

Signed-off-by: Jeff Mahoney <jeffm@xxxxxxxx>

diff -ruNpX dontdiff linux-2.6.16-rc4/drivers/net/tg3.c linux-2.6.16-rc4.tg3/drivers/net/tg3.c
--- linux-2.6.16-rc4/drivers/net/tg3.c 2006-02-20 13:52:40.000000000 -0500
+++ linux-2.6.16-rc4.tg3/drivers/net/tg3.c 2006-02-20 13:54:20.000000000 -0500
@@ -6443,6 +6443,8 @@ static int tg3_open(struct net_device *d
struct tg3 *tp = netdev_priv(dev);
int err;

+ netif_carrier_off(tp->dev);
+
tg3_full_lock(tp, 0);

tg3_disable_ints(tp);
@@ -10430,7 +10432,6 @@ static void __devinit tg3_init_link_conf
tp->link_config.speed = SPEED_INVALID;
tp->link_config.duplex = DUPLEX_INVALID;
tp->link_config.autoneg = AUTONEG_ENABLE;
- netif_carrier_off(tp->dev);
tp->link_config.active_speed = SPEED_INVALID;
tp->link_config.active_duplex = DUPLEX_INVALID;
tp->link_config.phy_is_low_power = 0;
--
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/