summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/legacy/inode.c
diff options
context:
space:
mode:
authorZhang Qilong <zhangqilong3@huawei.com>2020-11-17 05:16:29 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-02 10:34:45 +0300
commit121c9f539cc591f20b984d413205ac31e5b2e50e (patch)
tree4ebdf96ebd3dda5b230f6228e989ff790af2a71a /drivers/usb/gadget/legacy/inode.c
parente4c42e8bb567f130aeae98a7db9b8cb43a6d58e1 (diff)
downloadlinux-121c9f539cc591f20b984d413205ac31e5b2e50e.tar.xz
usb: gadget: Fix memleak in gadgetfs_fill_super
commit 87bed3d7d26c974948a3d6e7176f304b2d41272b upstream. usb_get_gadget_udc_name will alloc memory for CHIP in "Enomem" branch. we should free it before error returns to prevent memleak. Fixes: 175f712119c57 ("usb: gadget: provide interface for legacy gadgets to get UDC name") Reported-by: Hulk Robot <hulkci@huawei.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Link: https://lore.kernel.org/r/20201117021629.1470544-3-zhangqilong3@huawei.com Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/legacy/inode.c')
-rw-r--r--drivers/usb/gadget/legacy/inode.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index e431a8bc3a9d..e9f7f2660cd1 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -2044,6 +2044,9 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
return 0;
Enomem:
+ kfree(CHIP);
+ CHIP = NULL;
+
return -ENOMEM;
}