From: Sergey Vlasov Date: Mon, 10 Apr 2006 05:32:48 +0000 (-0700) Subject: [NET]: Fix hotplug race during device registration. X-Git-Tag: v2.6.17-rc2~291^2~4 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=9469d458b90bfb9117cbb488cfa645d94c3921b1;p=linux-2.6-omap-h63xx.git [NET]: Fix hotplug race during device registration. From: Thomas de Grenier de Latour On Sun, 9 Apr 2006 21:56:59 +0400, Sergey Vlasov wrote: > However, show_address() does not output anything unless > dev->reg_state == NETREG_REGISTERED - and this state is set by > netdev_run_todo() only after netdev_register_sysfs() returns, so in > the meantime (while netdev_register_sysfs() is busy adding the > "statistics" attribute group) some process may see an empty "address" > attribute. I've tried the attached patch, suggested by Sergey Vlasov on hotplug-devel@, and as far as i can test it works just fine. Signed-off-by: David S. Miller --- diff --git a/net/core/dev.c b/net/core/dev.c index dfb62998866..2731570eba5 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3042,11 +3042,11 @@ void netdev_run_todo(void) switch(dev->reg_state) { case NETREG_REGISTERING: + dev->reg_state = NETREG_REGISTERED; err = netdev_register_sysfs(dev); if (err) printk(KERN_ERR "%s: failed sysfs registration (%d)\n", dev->name, err); - dev->reg_state = NETREG_REGISTERED; break; case NETREG_UNREGISTERING: