Skip to content

Commit

Permalink
usb: gadget zero timer init fix
Browse files Browse the repository at this point in the history
Initialize timer earlier so if an error occurs allocating USB request
or buffer request (zero_bind) Gadget Zero will not hang trying to
delete an uninitialized timer (zero_unbind).

Signed-off-by: David Lopo <lopo.david@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
David Lopo authored and Greg Kroah-Hartman committed May 2, 2008
1 parent 7472f38 commit 7a6ad1d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/usb/gadget/zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@ static int __init zero_bind(struct usb_gadget *gadget)
dev->gadget = gadget;
set_gadget_data(gadget, dev);

init_timer(&dev->resume);
dev->resume.function = zero_autoresume;
dev->resume.data = (unsigned long) dev;

/* preallocate control response and buffer */
dev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
if (!dev->req)
Expand Down Expand Up @@ -1165,9 +1169,6 @@ static int __init zero_bind(struct usb_gadget *gadget)

usb_gadget_set_selfpowered(gadget);

init_timer(&dev->resume);
dev->resume.function = zero_autoresume;
dev->resume.data = (unsigned long) dev;
if (autoresume) {
source_sink_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
Expand Down

0 comments on commit 7a6ad1d

Please sign in to comment.