From: Yonghua Yan Date: Thu, 27 Dec 2018 03:48:34 +0000 (+0800) Subject: usb: configfs: synchronize the secure and udc_name state X-Git-Tag: MMI-QSAS30.62-33-3~120 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0851b9b1763c95e1b4fed752d1dd0527b34d9a65;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git usb: configfs: synchronize the secure and udc_name state The gadget driver unregister/probe is not allowed to reentry for the same udc. As the conditions for gadget driver unregister/probe entry, gadget secure and udc_name status should be synchronized. Otherwise, in old implement code logic, there is still a chance to fall into trouble of gadget driver unregister/probe reentry for the same udc. Change-Id: I6eb30a36eab84afd656f5bee9678e8d44933c6bc Signed-off-by: Yonghua Yan Reviewed-on: https://gerrit.mot.com/1287442 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Yuecai Liu Reviewed-by: Jianqi Yang Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1376191 Reviewed-by: Xiangpo Zhao --- diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index c8d1f9c95a24..beb9c932d495 100755 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1870,15 +1870,19 @@ static ssize_t secure_store(struct device *pdev, struct device_attribute *attr, mode = !!mode; if (mode == gi->secure) return count; + + mutex_lock(&gi->lock); + gi->secure = mode; - if (!gi->composite.gadget_driver.udc_name) + if (!gi->composite.gadget_driver.udc_name) { + mutex_unlock(&gi->lock); return count; + } pr_debug("Secure Store , UDC = %s, secure = %d\n", gi->composite.gadget_driver.udc_name, gi->secure); - mutex_lock(&gi->lock); if (gi->secure) { ret = usb_gadget_unregister_driver( &gi->composite.gadget_driver);