Commit d09b23c5 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[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.
parent 0a36f1fd
......@@ -721,7 +721,7 @@ static struct usb_class_driver dabusb_class = {
/* --------------------------------------------------------------------- */
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 @@ static int dabusb_probe (struct usb_interface *intf,
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 @@ static int dabusb_probe (struct usb_interface *intf,
}
}
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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment