Commit ce46794f authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

USB: gadgetfs behaves better on userspace init bug

Resolve an initizlization issue that could come up if the userspace
driver wrote invalid descriptors to a dual-speed device.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5b89db02
...@@ -1392,17 +1392,17 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) ...@@ -1392,17 +1392,17 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
spin_lock (&dev->lock); spin_lock (&dev->lock);
dev->setup_abort = 0; dev->setup_abort = 0;
if (dev->state == STATE_DEV_UNCONNECTED) { if (dev->state == STATE_DEV_UNCONNECTED) {
dev->state = STATE_DEV_CONNECTED;
dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket;
#ifdef CONFIG_USB_GADGET_DUALSPEED #ifdef CONFIG_USB_GADGET_DUALSPEED
if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) { if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) {
spin_unlock(&dev->lock);
ERROR (dev, "no high speed config??\n"); ERROR (dev, "no high speed config??\n");
return -EINVAL; return -EINVAL;
} }
#endif /* CONFIG_USB_GADGET_DUALSPEED */ #endif /* CONFIG_USB_GADGET_DUALSPEED */
dev->state = STATE_DEV_CONNECTED;
dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket;
INFO (dev, "connected\n"); INFO (dev, "connected\n");
event = next_event (dev, GADGETFS_CONNECT); event = next_event (dev, GADGETFS_CONNECT);
event->u.speed = gadget->speed; event->u.speed = gadget->speed;
......
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