1
0
Fork 0

usb: gadget: Fix memleak in gadgetfs_fill_super

commit 87bed3d7d2 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: 175f712119 ("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>
5.4-rM2-2.2.x-imx-squashed
Zhang Qilong 2020-11-17 10:16:29 +08:00 committed by Greg Kroah-Hartman
parent cad7b76a61
commit f69d749d5f
1 changed files with 3 additions and 0 deletions

View File

@ -2040,6 +2040,9 @@ gadgetfs_fill_super (struct super_block *sb, struct fs_context *fc)
return 0;
Enomem:
kfree(CHIP);
CHIP = NULL;
return -ENOMEM;
}