Skip to content

Commit

Permalink
usb: gadget: f_mass_storage: stop thread in bind failure case
Browse files Browse the repository at this point in the history
After the worker thread is launched, bind function is doing further
configuration. In case of failure stop the thread.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Sanjay Singh Rawat <snjsrwt@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Sanjay Singh Rawat authored and Felipe Balbi committed Jul 30, 2015
1 parent 5feb5d2 commit 8078f31
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/usb/gadget/function/f_mass_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3081,7 +3081,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
/* New interface */
i = usb_interface_id(c, f);
if (i < 0)
return i;
goto fail;
fsg_intf_desc.bInterfaceNumber = i;
fsg->interface_number = i;

Expand Down Expand Up @@ -3124,7 +3124,14 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)

autoconf_fail:
ERROR(fsg, "unable to autoconfigure all endpoints\n");
return -ENOTSUPP;
i = -ENOTSUPP;
fail:
/* terminate the thread */
if (fsg->common->state != FSG_STATE_TERMINATED) {
raise_exception(fsg->common, FSG_STATE_EXIT);
wait_for_completion(&fsg->common->thread_notifier);
}
return i;
}

/****************************** ALLOCATE FUNCTION *************************/
Expand Down

0 comments on commit 8078f31

Please sign in to comment.