]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] Fix hotplug race during device registration
authorThomas de Grenier de Latour <degrenier@easyconnect.fr>
Wed, 19 Apr 2006 04:22:39 +0000 (10:22 +0600)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 24 Apr 2006 16:56:03 +0000 (09:56 -0700)
On Sun, 9 Apr 2006 21:56:59 +0400,
Sergey Vlasov <vsu@altlinux.ru> 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: Alexander Patrakov <patrakov@ums.usu.ru>
Signed-off-by: David Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/core/dev.c

index 2afb0de953291c3dfb2e16b25ba764a43e3cd860..12a214c4e80192c389ac682a474cfe58f0f4a1e3 100644 (file)
@@ -2932,11 +2932,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: