net: Do not fire linkwatch events until the device is registered.

Several device drivers try to do things like netif_carrier_off()
before register_netdev() is invoked. This is bogus, but too many
drivers do this to fix them all up in one go.

Reported-by: Folkert van Heusden <folkert@vanheusden.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

+6 -1
+6 -1
net/sched/sch_generic.c
··· 270 270 void netif_carrier_on(struct net_device *dev) 271 271 { 272 272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 273 + if (dev->reg_state == NETREG_UNINITIALIZED) 274 + return; 273 275 linkwatch_fire_event(dev); 274 276 if (netif_running(dev)) 275 277 __netdev_watchdog_up(dev); ··· 287 285 */ 288 286 void netif_carrier_off(struct net_device *dev) 289 287 { 290 - if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) 288 + if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 289 + if (dev->reg_state == NETREG_UNINITIALIZED) 290 + return; 291 291 linkwatch_fire_event(dev); 292 + } 292 293 } 293 294 EXPORT_SYMBOL(netif_carrier_off); 294 295