Patchwork Re: [2.6.26] OOPS in __linkwatch_run_queue (unable to handle kernel NULL pointer dereference at 00000235)

login
register
mail settings
Submitter David Miller
Date Nov. 19, 2008, 11:35 p.m.
Message ID <20081119.153545.42955147.davem@davemloft.net>
Download mbox | patch
Permalink /patch/9665/
State Accepted
Delegated to: David Miller
Headers show

Comments

David Miller - Nov. 19, 2008, 11:35 p.m.
From: David Miller <davem@davemloft.net>
Date: Mon, 17 Nov 2008 01:15:09 -0800 (PST)

> From: Jarek Poplawski <jarkao2@gmail.com>
> Date: Mon, 17 Nov 2008 09:11:08 +0000
> 
> > On Mon, Nov 17, 2008 at 12:50:25AM -0800, David Miller wrote:
> > Yes, this looks very nice! But this should be done in "a few" more
> > drivers, like cxgb3 etc.
> 
> Thanks for pointing that out, I'll fix those cases too.

I did an audit, and found that this construct is too pervasive to
fix right now.  Even e1000 and e1000e do this call of netif_carrier_off()
before the device is even registered.

So here is the bandaid I'll use to fix the bug in 2.6.28

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>
---
 net/sched/sch_generic.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Patch

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 93cd30c..cdcd16f 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -270,6 +270,8 @@  static void dev_watchdog_down(struct net_device *dev)
 void netif_carrier_on(struct net_device *dev)
 {
 	if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
+		if (dev->reg_state == NETREG_UNINITIALIZED)
+			return;
 		linkwatch_fire_event(dev);
 		if (netif_running(dev))
 			__netdev_watchdog_up(dev);
@@ -285,8 +287,11 @@  EXPORT_SYMBOL(netif_carrier_on);
  */
 void netif_carrier_off(struct net_device *dev)
 {
-	if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state))
+	if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
+		if (dev->reg_state == NETREG_UNINITIALIZED)
+			return;
 		linkwatch_fire_event(dev);
+	}
 }
 EXPORT_SYMBOL(netif_carrier_off);