OSDN Git Service

usb: gadget: f_fs: Queue request after setting is_busy flag
authorAjay Agarwal <ajaya@codeaurora.org>
Mon, 11 Mar 2019 11:28:06 +0000 (16:58 +0530)
committerAjay Agarwal <ajaya@codeaurora.org>
Wed, 27 Mar 2019 04:12:46 +0000 (09:42 +0530)
Currently the driver queues OUT EP request after ensuring that
is_busy flag is false, and then sets it true. It might be
possible that the queued request is completed before the
execution reaches next line to set is_busy to true. As a result,
is_busy remains true even after successful completion and no
further request is queued.
Fix this by first setting is_busy to true and then queueing the
request.

Change-Id: I87fce4e2cc94be8e6b6fb63fb1fc9afb9cf0d005
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
drivers/usb/gadget/function/f_fs.c

index f971930..fd2150a 100644 (file)
@@ -988,13 +988,14 @@ retry:
                         * still busy.
                         */
                        if (!(io_data->read && ep->is_busy)) {
-                               ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
                                ep->is_busy = true;
+                               ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
                        }
 
                        spin_unlock_irq(&epfile->ffs->eps_lock);
 
                        if (unlikely(ret < 0)) {
+                               ep->is_busy = false;
                                ret = -EIO;
                        } else if (unlikely(
                                   wait_for_completion_interruptible(done))) {