On Wed, Sep 14, 2011 at 04:27:39PM +0200, EXTERNAL Konold Martin (Firma, RtP2/TEF72) wrote:
Hi,
I am experiencing a race in the usb stack when using different drivers for different hardware sharing the same major number.
What drivers would that be? Any pointers to them? We don't usually allow this at all.
When trying to hunting down the problem I encountered the function
usb_register_dev(struct usb_interface *intf, struct usb_class_driver *class_driver)
in drivers/usb/core/file.c
There is a call to init_usb_class() which access
static struct usb_class { struct kref kref; struct class *class; } *usb_class;
without explicit access protection.
To me it looks like I can observe a race in usb_register_dev() when doing a coldplug during bootup of the system. (OpenSUSE 11.3)
In my test setup I have 3 different but similar devices which all call usb_register_dev() from file.c concurrently as seen in the debug output.
As the USB subsystem init path is serialized, I don't see how this can be happening. What is creating these calls in a parallel manner? And does this also happen with the 11.4 kernel, and the 3.0 kernel in Kernel:stable? The 11.3 kernel is quite old at this point in time from a development point-of-view.
Within usb_register_dev() there is a call to device_create(usb_class->class, &intf->dev, MKDEV(USB_MAJOR, minor), class_driver, "%s", temp). Within device_create() there is a call to device_create_vargs() which returns ENODEV (19)
struct device * device_create_vargs(class, parent, devt, drvdata, fmt, vargs)
The callstack then looks like usb_register_dev() device_create() device_create_vargs() <-- returns ENODEV in case of the race condition
I am now wondering if my observations and thoughts are reasonable. Assuming that there is indeed such a race I would like to know if the following trivial patch is the correct approach?
Actually, in looking at your patch, I think this might be correct. Care to refresh it against the 3.0 kernel tree, and provide the proper Signed-off-by: line and cc: it to the linux-usb@vger.kernel.org mailing list and me, and we can take it from there? thanks, greg k-h -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org