From 75e7d849855c3941bcef6f9e9916310334f63a9c Mon Sep 17 00:00:00 2001 From: a17671 Date: Fri, 8 Nov 2019 10:48:21 +0800 Subject: [PATCH] usb:Balance the enable/disable in secure mode 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 Reviewed-on: https://gerrit.mot.com/1451197 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/usb/gadget/configfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 8dd6ea47a6de..3d2e8fca5145 100755 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -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(); -- 2.20.1