ChangeSet 1.1455.1.42, 2003/07/17 14:47:19-07:00, oliver@neukum.org [PATCH] USB: fix race between probe and open in dabusb the driver is registering the device too early, so that open may see a partially initialised device. drivers/usb/media/dabusb.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c --- a/drivers/usb/media/dabusb.c Thu Jul 17 17:03:16 2003 +++ b/drivers/usb/media/dabusb.c Thu Jul 17 17:03:16 2003 @@ -721,7 +721,7 @@ /* --------------------------------------------------------------------- */ -static int dabusb_probe (struct usb_interface *intf, +static int dabusb_probe (struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *usbdev = interface_to_usbdev(intf); @@ -738,9 +738,7 @@ if (intf->altsetting->desc.bInterfaceNumber != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999) return -ENODEV; - retval = usb_register_dev(intf, &dabusb_class); - if (retval) - return -ENOMEM; + s = &dabusb[intf->minor]; @@ -766,8 +764,15 @@ } } dbg("bound to interface: %d", ifnum); - up (&s->mutex); usb_set_intfdata (intf, s); + up (&s->mutex); + + retval = usb_register_dev(intf, &dabusb_class); + if (retval) { + usb_set_intfdata (intf, NULL); + return -ENOMEM; + } + return 0; reject: