usb:Balance the enable/disable in secure mode
authora17671 <a17671@motorola.com>
Fri, 8 Nov 2019 02:48:21 +0000 (10:48 +0800)
committerlingsen1 <lingsen1@lenovo.com>
Sun, 7 Feb 2021 09:37:05 +0000 (17:37 +0800)
Enable/Disable shall be banlanced when USB in secure mode
Otherwise the linked_func and func_list could be messed up
That will cause the unbinding release the wild memory
This is a Samsung platform only issue,kernel panic
Has the following mark:

configfs-gadget gadget:unbind function 'mtp'
configfs-gadget gadget:unbind function 'ptp'

Which shall not happen, since user could not choose
Both mtp and ptp together

Change-Id: I4aba691a0c4180f828c55aad5d63b9162c3f881a
Signed-off-by: a17671 <a17671@motorola.com>
Reviewed-on: https://gerrit.mot.com/1451197
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/configfs.c

index 8dd6ea47a6de4c2a0c477da3d7c640522d8eb440..3d2e8fca514501aa84e29c7722871dfbb0c1da54 100755 (executable)
@@ -1776,6 +1776,7 @@ static ssize_t enable_store(struct device *pdev, struct device_attribute *attr,
 #else
                cdev->next_string_id = 0;
 #endif
+       if (!dev->secure) {
                if (!gadget) {
                        pr_info("%s: Gadget is NULL: %p\n", __func__, gadget);
                        mutex_unlock(&dev->lock);
@@ -1783,6 +1784,7 @@ static ssize_t enable_store(struct device *pdev, struct device_attribute *attr,
                }
 
                usb_gadget_connect(gadget);
+       }
                dev->enabled = true;
 #ifdef CONFIG_USB_TYPEC_MANAGER_NOTIFIER
                set_usb_enable_state();