diff options
| -rw-r--r-- | drivers/usb/gadget/file_storage.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 5779549d7dc6..3ac4f51cd0bb 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
| @@ -3153,6 +3153,15 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget) | |||
| 3153 | DBG(fsg, "unbind\n"); | 3153 | DBG(fsg, "unbind\n"); |
| 3154 | clear_bit(REGISTERED, &fsg->atomic_bitflags); | 3154 | clear_bit(REGISTERED, &fsg->atomic_bitflags); |
| 3155 | 3155 | ||
| 3156 | /* If the thread isn't already dead, tell it to exit now */ | ||
| 3157 | if (fsg->state != FSG_STATE_TERMINATED) { | ||
| 3158 | raise_exception(fsg, FSG_STATE_EXIT); | ||
| 3159 | wait_for_completion(&fsg->thread_notifier); | ||
| 3160 | |||
| 3161 | /* The cleanup routine waits for this completion also */ | ||
| 3162 | complete(&fsg->thread_notifier); | ||
| 3163 | } | ||
| 3164 | |||
| 3156 | /* Unregister the sysfs attribute files and the LUNs */ | 3165 | /* Unregister the sysfs attribute files and the LUNs */ |
| 3157 | for (i = 0; i < fsg->nluns; ++i) { | 3166 | for (i = 0; i < fsg->nluns; ++i) { |
| 3158 | curlun = &fsg->luns[i]; | 3167 | curlun = &fsg->luns[i]; |
| @@ -3166,15 +3175,6 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget) | |||
| 3166 | } | 3175 | } |
| 3167 | } | 3176 | } |
| 3168 | 3177 | ||
| 3169 | /* If the thread isn't already dead, tell it to exit now */ | ||
| 3170 | if (fsg->state != FSG_STATE_TERMINATED) { | ||
| 3171 | raise_exception(fsg, FSG_STATE_EXIT); | ||
| 3172 | wait_for_completion(&fsg->thread_notifier); | ||
| 3173 | |||
| 3174 | /* The cleanup routine waits for this completion also */ | ||
| 3175 | complete(&fsg->thread_notifier); | ||
| 3176 | } | ||
| 3177 | |||
| 3178 | /* Free the data buffers */ | 3178 | /* Free the data buffers */ |
| 3179 | for (i = 0; i < fsg_num_buffers; ++i) | 3179 | for (i = 0; i < fsg_num_buffers; ++i) |
| 3180 | kfree(fsg->buffhds[i].buf); | 3180 | kfree(fsg->buffhds[i].buf); |
