Skip to content

Commit 8078f31

Browse files
Sanjay Singh RawatFelipe Balbi
authored andcommitted
usb: gadget: f_mass_storage: stop thread in bind failure case
After the worker thread is launched, bind function is doing further configuration. In case of failure stop the thread. Acked-by: Michal Nazarewicz <[email protected]> Signed-off-by: Sanjay Singh Rawat <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 5feb5d2 commit 8078f31

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/usb/gadget/function/f_mass_storage.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,7 +3081,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
30813081
/* New interface */
30823082
i = usb_interface_id(c, f);
30833083
if (i < 0)
3084-
return i;
3084+
goto fail;
30853085
fsg_intf_desc.bInterfaceNumber = i;
30863086
fsg->interface_number = i;
30873087

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

31253125
autoconf_fail:
31263126
ERROR(fsg, "unable to autoconfigure all endpoints\n");
3127-
return -ENOTSUPP;
3127+
i = -ENOTSUPP;
3128+
fail:
3129+
/* terminate the thread */
3130+
if (fsg->common->state != FSG_STATE_TERMINATED) {
3131+
raise_exception(fsg->common, FSG_STATE_EXIT);
3132+
wait_for_completion(&fsg->common->thread_notifier);
3133+
}
3134+
return i;
31283135
}
31293136

31303137
/****************************** ALLOCATE FUNCTION *************************/

0 commit comments

Comments
 (0)