From: David Brownell Date: Wed, 17 Jan 2007 07:06:07 +0000 (-0800) Subject: USB: gadgetfs behaves better on userspace init bug X-Git-Tag: upstream/snapshot3+hdmi~35680^2~9^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce46794f77f698eaf3b80922fafac5a9379085e0;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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: David Brownell Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index e5ce4f0..1c5e1ee 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1392,17 +1392,17 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) spin_lock (&dev->lock); dev->setup_abort = 0; if (dev->state == STATE_DEV_UNCONNECTED) { - - dev->state = STATE_DEV_CONNECTED; - dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket; - #ifdef CONFIG_USB_GADGET_DUALSPEED if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) { + spin_unlock(&dev->lock); ERROR (dev, "no high speed config??\n"); return -EINVAL; } #endif /* CONFIG_USB_GADGET_DUALSPEED */ + dev->state = STATE_DEV_CONNECTED; + dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket; + INFO (dev, "connected\n"); event = next_event (dev, GADGETFS_CONNECT); event->u.speed = gadget->speed;