On Wed, Nov 18, 2009 at 7:27 AM, Oliver Neukum <oliver@xxxxxxxxxx> wrote: > Am Mittwoch, 18. November 2009 11:41:25 schrieb Jiri Kosina: >> > User space receives the hotplug event for the class device, makes the >> > device node and notifies another program that opens the device node. >> > The program opens the device node which calls into usb_open and then >> > skel_open. skel_open calls usb_find_interface. usb_find_interfaces >> > searches the klist_devices of skel_driver, finds no device associated >> > with the minor number and returns NULL. skel_open returns -ENODEV. >> > >> > Control returns to really_probe and really_probe calls driver_bound >> > which adds the device to the list of devices associated with >> > skel_driver (klist_devices). >> > >> > I'm not sure what the right way to solve this is. A call to >> > wait_for_device_probe() in the skel_open call before calling >> > usb_find_interface fixes the problem, but it is a rather large hammer. >> > > Device core code is hard to follow, but I tried. > How about simply covering all of usb_register_dev() with minor_rwsem? > The race is open from the point that usb_register_dev calls device_create (at the end of usb_register_dev) till the point that skel_probe returns up to the point of really_probe, really_probe calls driver_bound, and driver_bound adds the device to the driver's klist_devices. call stack: device_create usb_register_dev skel_probe usb_probe_device (via drv->probe()) really_probe really_probe: dev->driver = drv; if (driver_sysfs_add(dev)) { [...] } if (dev->bus->probe) { [...] } else if (drv->probe) { -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html