From: Yonghua Yan Date: Tue, 25 Jun 2019 06:04:04 +0000 (+0800) Subject: usb: configfs: skip unregister gadget in secure X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0567beba869d348f0eec6932424ce229e4122d90;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git usb: configfs: skip unregister gadget in secure There will be gadget driver unregister twice in USB secure when try to set the UDC to none from userspace, which will cause kernel panic in 4.9 kernel version, as there is a feature about pending gadget driver list being added in this version. As a solution, make sure gadget driver unregister or probe only once over secure mode entry or usb configure from userspace. Kernel BUG at ffffff8093067140 [verbose debug info unavailable] Internal error: Accessing user space memory outside uaccess.h Change-Id: I89f03afbf9716a95aae37e354cc0cb293b2ea090 Signed-off-by: a17671 Reviewed-on: https://gerrit.mot.com/1376192 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index beb9c932d495..cd7cdaa3cad0 100755 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -284,6 +284,12 @@ static int unregister_gadget(struct gadget_info *gi) if (!gi->composite.gadget_driver.udc_name) return -ENODEV; + if (gi->secure) { + kfree(gi->composite.gadget_driver.udc_name); + gi->composite.gadget_driver.udc_name = NULL; + return 0; + } + ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver); if (ret) return ret;