Prevent "eth0: driver changed get_stats after register" lying
Subsystems (2)
PATCH 1/1 Prevent "eth0: driver changed get_stats after register" lying
Hi,
There appears to be a race condition between netdev_register_sysfs and hotplug. I'm seeing the message in the subject upon initialisation of pcnet_cs.
We set "dev->last_stats" after we have registered the class device. During class device registration, we trigger the hotplug scripts, which can in turn bring up the interface. This in turn checks to see if "dev->last_stats == dev->get_stats", and, since we haven't set dev->last_stats yet, we complain.
Here is a patch against 2.6.0-test8 which moves the initialisation of last_stats such that we avoid the race.
net/core/net-sysfs.c +1 -1
@@ -408,6 +408,7 @@ class_dev->class = &net_class; class_dev->class_data = net; + net->last_stats = net->get_stats;strlcpy (class_dev->class_id, net->name,BUS_ID_SIZE );if ((ret =class_device_register (class_dev)))
@@ -419,7 +420,6 @@ } - net->last_stats = net->get_stats;if (net->get_stats && (ret =sysfs_create_group (&class_dev->kobj, &netstat_group))) goto out_unreg;
Signature · 4 lines
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial coreQuoted 9 lines · Russell King
There appears to be a race condition between
netdev_register_sysfsand hotplug. I'm seeing the message in the subject upon initialisation ofpcnet_cs.We set "
dev->last_stats" after we have registered the class device. During class device registration, we trigger the hotplug scripts, which can in turn bring up the interface. This in turn checks to see if "dev->last_stats==dev->get_stats", and, since we haven't setdev->last_statsyet, we complain.
Incidentally, this also means that hotplug scripts can run before we've registered the class device attributes. Could that be another problem? It's probably something that the hotplug people should be aware of.
Signature · 4 lines
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial coreQuoted 8 lines · On Sat, 18 Oct 2003 21:46:22 +0100 Russell King <[email protected]> wrote:
We set "
dev->last_stats" after we have registered the class device. During class device registration, we trigger the hotplug scripts, which can in turn bring up the interface. This in turn checks to see if "dev->last_stats==dev->get_stats", and, since we haven't setdev->last_statsyet, we complain.Here is a patch against 2.6.0-test8 which moves the initialisation of
last_statssuch that we avoid the race.
Looks ok, thanks Russell.