After the worker thread is launched, bind function is doing further configuration. Stop the thread in case of failure. Also use kthread_run to encapsulate thread creation and launch. Signed-off-by: Sanjay Singh Rawat <snjsrwt@xxxxxxxxx> --- drivers/usb/gadget/function/f_mass_storage.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 3cc109f..835764a 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -3005,7 +3005,7 @@ int fsg_common_run_thread(struct fsg_common *common) common->state = FSG_STATE_IDLE; /* Tell the thread to start working */ common->thread_task = - kthread_create(fsg_main_thread, common, "file-storage"); + kthread_run(fsg_main_thread, common, "file-storage"); if (IS_ERR(common->thread_task)) { common->state = FSG_STATE_TERMINATED; return PTR_ERR(common->thread_task); @@ -3013,8 +3013,6 @@ int fsg_common_run_thread(struct fsg_common *common) DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task)); - wake_up_process(common->thread_task); - return 0; } EXPORT_SYMBOL_GPL(fsg_common_run_thread); @@ -3082,7 +3080,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; @@ -3125,7 +3123,10 @@ 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: + kthread_stop(fsg->common->thread_task); + return i; } /****************************** ALLOCATE FUNCTION *************************/ -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html