Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a6ad1dd authored by David Lopo's avatar David Lopo Committed by Greg Kroah-Hartman
Browse files

usb: gadget zero timer init fix



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: default avatarDavid Lopo <lopo.david@gmail.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7472f38b
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -1134,6 +1134,10 @@ static int __init zero_bind(struct usb_gadget *gadget)
	dev->gadget = gadget;
	dev->gadget = gadget;
	set_gadget_data(gadget, dev);
	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 */
	/* preallocate control response and buffer */
	dev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
	dev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
	if (!dev->req)
	if (!dev->req)
@@ -1165,9 +1169,6 @@ static int __init zero_bind(struct usb_gadget *gadget)


	usb_gadget_set_selfpowered(gadget);
	usb_gadget_set_selfpowered(gadget);


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