From: a17671 Date: Mon, 18 Nov 2019 07:56:16 +0000 (+0800) Subject: usb:Restore linked_func list in none-secure mode X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9c250a22757e697cc984106f98dcf401a1854717;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git usb:Restore linked_func list in none-secure mode In none-secure mode, there is still A low chance of gadget NULL case, Restore the binded functions list back to Linked_func list, so next time unbind functions Could be handled correctly without memory corruption This is a Samsung platform only issue Change-Id: Ie46fc52d3eaa6ef60c1a4f6bb83a56229Montana854d Signed-off-by: a17671 Reviewed-on: https://gerrit.mot.com/1456923 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver 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 3d2e8fca5145..4ad3a08beb7b 100755 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1779,6 +1779,14 @@ static ssize_t enable_store(struct device *pdev, struct device_attribute *attr, if (!dev->secure) { if (!gadget) { pr_info("%s: Gadget is NULL: %p\n", __func__, gadget); + list_for_each_entry(c, &cdev->configs, list) { + cfg = container_of(c, struct config_usb_cfg, c); + list_for_each_entry_safe(f, tmp, &cfg->func_list, list) { + list_move_tail(&f->list, &dev->linked_func); + } + c->next_interface_id = 0; + memset(c->interface, 0, sizeof(c->interface)); + } mutex_unlock(&dev->lock); return -ENODEV; }