Received: by 10.223.176.5 with SMTP id f5csp1024211wra; Fri, 2 Feb 2018 09:54:08 -0800 (PST) X-Google-Smtp-Source: AH8x226t08H3dhMEgx4lVXrYtXEqPBczdSfS3Thundz4UBerwQ6nsoMGG/1G8ywbzGiO+pOzkwtG X-Received: by 10.98.213.130 with SMTP id d124mr40869806pfg.112.1517594048035; Fri, 02 Feb 2018 09:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594048; cv=none; d=google.com; s=arc-20160816; b=GQljhtlkr7fhr1JCg1UwHr4E0SSElWu5li3cap+HsRRe3I0PGVuVaBhLrx2PAwEEs4 w8wwnFkMOPLGSBjQ4Lsz1v2QH27A8zJkFJrKe0YNb6AKfRfr5endIXfwEiY4xz5wx/8T +3NgmflJUVzU2ZbXkwR/dBoIiNYkcBFHjKDXA4BpsjCncPS7qzri3wFEEKVokzkbuj2Z N7RKmbjmnrZU0OyQlz1RVg6p3p8SF1YvSz1KuR+zQ1pIR6nTeR6556pGYzarNY5jEkcx 35B07NPqcv1yYZyK8XEyezRF/UJSHvGpCn2KbJ//z1vRXNXHnp21yx6l2AWKxLpU5auk ELDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=V5BUlqWxkEoTI+3s9XqXbVJb4aBz/TmOX/u89O6O6vM=; b=r5tPco847hjdzy7tzsF4NA2mPy9u1ZBHga2hJtGooJ8zZgJHreQj4JwPom79dxWOGl ile0xZ2CNnBdu5vfpLfMwOeV+AagOx+OpMemkZeQsAV2JoXqheBL7vgW4wyeYqaSlQkU 5T+ssC3jmSkkI4hX2o4kPcU3FwR7tchWNqTz4/JINBYEYeWRzHFd/qXLv7WBi0fdVZz6 nbi4SITgRFplaHob4Nh3hUsyy6o7N5YEq47O18UAexSPu8qhE8oNzrLqw6cHd7/boA0b rnv8Eglw4VuhN1aWEbDxi46vwi8Y44vyXTzx6I/xizJO41EoCCQUUeeH9yrecNtKtM2T fvvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si1428pgc.386.2018.02.02.09.53.53; Fri, 02 Feb 2018 09:54:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753465AbeBBRMZ (ORCPT + 99 others); Fri, 2 Feb 2018 12:12:25 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36772 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753100AbeBBRG3 (ORCPT ); Fri, 2 Feb 2018 12:06:29 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6EC98E8D; Fri, 2 Feb 2018 17:06:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Balbi , Michal Nazarewicz , John Stultz , Dmitry Shmidt , Badhri , Android Kernel Team , Hemant Kumar , Amit Pundir , Greg KH Subject: [PATCH 4.9 81/86] usb: f_fs: Prevent gadget unbind if it is already unbound Date: Fri, 2 Feb 2018 17:58:41 +0100 Message-Id: <20180202140830.100425500@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140822.679101338@linuxfoundation.org> References: <20180202140822.679101338@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hemant Kumar commit ce5bf9a50daf2d9078b505aca1cea22e88ecb94a upstream. Upon usb composition switch there is possibility of ep0 file release happening after gadget driver bind. In case of composition switch from adb to a non-adb composition gadget will never gets bound again resulting into failure of usb device enumeration. Fix this issue by checking FFS_FL_BOUND flag and avoid extra gadget driver unbind if it is already done as part of composition switch. This fixes adb reconnection error reported on Android running v4.4 and above kernel versions. Verified on Hikey running vanilla v4.15-rc7 + few out of tree Mali patches. Reviewed-at: https://android-review.googlesource.com/#/c/582632/ Cc: Felipe Balbi Cc: Greg KH Cc: Michal Nazarewicz Cc: John Stultz Cc: Dmitry Shmidt Cc: Badhri Cc: Android Kernel Team Signed-off-by: Hemant Kumar [AmitP: Cherry-picked it from android-4.14 and updated the commit log] Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -3725,7 +3725,8 @@ static void ffs_closed(struct ffs_data * ci = opts->func_inst.group.cg_item.ci_parent->ci_parent; ffs_dev_unlock(); - unregister_gadget_item(ci); + if (test_bit(FFS_FL_BOUND, &ffs->flags)) + unregister_gadget_item(ci); return; done: ffs_dev_unlock();