Commit b47300168e770b60ab96c8924854c3b0eb4260eb
1 parent
566521d637
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff
net/sched/sch_generic.c
... | ... | @@ -270,6 +270,8 @@ |
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); |
276 | 278 | |
... | ... | @@ -285,8 +287,11 @@ |
285 | 287 | */ |
286 | 288 | void netif_carrier_off(struct net_device *dev) |
287 | 289 | { |
288 | - if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) | |
290 | + if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) { | |
291 | + if (dev->reg_state == NETREG_UNINITIALIZED) | |
292 | + return; | |
289 | 293 | linkwatch_fire_event(dev); |
294 | + } | |
290 | 295 | } |
291 | 296 | EXPORT_SYMBOL(netif_carrier_off); |
292 | 297 |