usb: gadget: inode.c: fix unbalanced spin_lock in ep0_write
authorDavid Eccher <d.eccher@gmail.com>
Fri, 11 Dec 2015 21:13:55 +0000 (22:13 +0100)
committerFelipe Balbi <balbi@ti.com>
Wed, 16 Dec 2015 21:19:11 +0000 (15:19 -0600)
Fix bad unlock balance: ep0_write enter with the locks locked from
inode.c:1769, hence it must exit with spinlock held to avoid double
unlock in dev_config.

Signed-off-by: David Eccher <d.eccher@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/legacy/inode.c

index f454c7af489ce050dba446a1a5a6b292ad179644..365afd7e14f8cade738683a06616b4116fa84fc9 100644 (file)
@@ -1137,10 +1137,9 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
                                                dev->gadget->ep0, dev->req,
                                                GFP_KERNEL);
                                }
+                               spin_lock_irq(&dev->lock);
                                if (retval < 0) {
-                                       spin_lock_irq (&dev->lock);
                                        clean_req (dev->gadget->ep0, dev->req);
-                                       spin_unlock_irq (&dev->lock);
                                } else
                                        retval = len;