OSDN Git Service

Merge android-4.4.187 (8eb3d65) into msm-4.4
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / usb / gadget / function / f_fs.c
index 5ccc098..d2a119b 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))) {
@@ -1166,11 +1167,12 @@ static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from)
        ffs_log("enter");
 
        if (!is_sync_kiocb(kiocb)) {
-               p = kmalloc(sizeof(io_data), GFP_KERNEL);
+               p = kzalloc(sizeof(io_data), GFP_KERNEL);
                if (unlikely(!p))
                        return -ENOMEM;
                p->aio = true;
        } else {
+               memset(p, 0, sizeof(*p));
                p->aio = false;
        }
 
@@ -1207,11 +1209,12 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to)
        ffs_log("enter");
 
        if (!is_sync_kiocb(kiocb)) {
-               p = kmalloc(sizeof(io_data), GFP_KERNEL);
+               p = kzalloc(sizeof(io_data), GFP_KERNEL);
                if (unlikely(!p))
                        return -ENOMEM;
                p->aio = true;
        } else {
+               memset(p, 0, sizeof(*p));
                p->aio = false;
        }
 
@@ -3565,7 +3568,7 @@ static int ffs_func_setup(struct usb_function *f,
 
        ffs_log("exit");
 
-       return USB_GADGET_DELAYED_STATUS;
+       return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
 }
 
 static void ffs_func_suspend(struct usb_function *f)