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)
committerPDO SCM Team <hudsoncm@motorola.com>
Tue, 14 Jun 2022 07:00:26 +0000 (02:00 -0500)
commit 89f3594d0de58e8a57d92d497dea9fee3d4b9cda upstream.

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

Mot-CRs-fixed: (CR)
CVE-Fixed: CVE-2022-24958
Bug: 220261709

Change-Id: I0eb72bf758a7909ce31e2aa960ed0583b1632a95
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>
Signed-off-by: Gajjala Chakradhar <gajjalac@motorola.com>
Reviewed-on: https://gerrit.mot.com/2276113
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

drivers/usb/gadget/legacy/inode.c

index d730a5c2b4fe183778f97287bdeb92bae9757bb0..f5936d17bd91ca05af4709d3fa506f34cb36446e 100644 (file)
@@ -1834,8 +1834,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;