From df30b04c71ffd9ae5f937108025fa9e06c80842e Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Tue, 13 Feb 2018 18:36:37 -0800 Subject: [PATCH] USB: f_fs: Set ffs->func to NULL after disabling endpoint in set_alt() When adb root is performed, userspace will close and open ffs_epsfile. Closing this file will call ffs_functionfs_callback() which does call remove_config(). This will call ffs_function_eps_disable to disable endpoints and then calls ffs_func_unbind(). Unbind() will also call endpoint disable which might lead to disabling endpoint which is already disabled. Hence set ffs->func to NULL after disabling endpoints in set_alt(). CRs-Fixed: 557532 Change-Id: I3052bdee74a1793d4e003de4b991d353e5d699b0 Signed-off-by: Vijayavardhan Vennapusa Signed-off-by: Mayank Rana Signed-off-by: Jack Pham --- drivers/usb/gadget/function/f_fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index e7de34d1a939..c92f8e8d1e56 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -3561,8 +3561,10 @@ static int ffs_func_set_alt(struct usb_function *f, return intf; } - if (ffs->func) + if (ffs->func) { ffs_func_eps_disable(ffs->func); + ffs->func = NULL; + } if (ffs->state == FFS_DEACTIVATED) { ffs->state = FFS_CLOSING;