]> git.hungrycats.org Git - linux/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Oct 2017 09:27:30 +0000 (11:27 +0200)
commit b7bd98b7db9fc8fe19da1a5ff0215311c6b95e46 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/legacy/inode.c

index 43ce2cfcdb4d93c1648ed3c3160109f4f8b3039f..2edb6948c55292a3aa131e0ce6f63fc45f1dcf06 100644 (file)
@@ -1140,10 +1140,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;