]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
usb: gadget: don't release an existing dev->buf
authorHangyu Hua <hbh25y@gmail.com>
Fri, 31 Dec 2021 17:21:37 +0000 (01:21 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Mar 2022 18:09:30 +0000 (19:09 +0100)
commit 89f3594d0de58e8a57d92d497dea9fee3d4b9cda upstream.

dev->buf does not need to be released if it already exists before
executing dev_config.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Link: https://lore.kernel.org/r/20211231172138.7993-2-hbh25y@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/legacy/inode.c

index 217d2b66fa514ac09488478608b4bf0965ed614d..74fb499219fa47cc09a74030bd7f6a71822e5687 100644 (file)
@@ -1828,8 +1828,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
        spin_lock_irq (&dev->lock);
        value = -EINVAL;
        if (dev->buf) {
+               spin_unlock_irq(&dev->lock);
                kfree(kbuf);
-               goto fail;
+               return value;
        }
        dev->buf = kbuf;