Received: by 10.223.176.5 with SMTP id f5csp1021892wra; Fri, 2 Feb 2018 09:51:31 -0800 (PST) X-Google-Smtp-Source: AH8x224LUqg0f0hX+QNcNqXljvL1JepDSP5rWBDEPrOyy1dATk8pioYVVsYL42CLkIZNY/l1hxSU X-Received: by 10.98.213.130 with SMTP id d124mr40865024pfg.112.1517593891362; Fri, 02 Feb 2018 09:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517593891; cv=none; d=google.com; s=arc-20160816; b=ih5Pppt8XVaxdhLkP5rvZIMo7i6Yjl2b+MKED7FtiRlvwGeK99H9mzFY57Ue7e9CE/ V3m2uUytMHnrp9FLDGPTvDP6EEr80CF/p34/yLbcQi3zsl758FOtu07FzuEEe3N4TG8v qkgcoE0P/PMu5iV84y/WRNoDmwNa7qU4RUr6+oYNCPBi+j2TJuYT4+BPSsd6Swle8kDz nBFeFXOEkZI7ghlG3neKtSk9W0pikT1QGJ7JDt9WqbYaLAJrqKTIwIzLb0qBPrh0upzx JmCbO06gmAQuyiALOyOeoplNVkKuDkLqjg7prI6iXyQCchMkNQNghFiHFrp0sVTpwUf1 iT9g== 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=oVQaQ9FCUXFBY56lDJHrvEU1P8WYWRLykaYoWS56DUM=; b=DPdyna9N4p7LLJkwPUywcBu1SV7G1KnucuG2WWNSIFfu74HL0Mmd+4+EF8q7n3DKVo DC1JeBHLrO04HKK3peE7Wg8MlKG+/zslbnjKHwaQ/eSgqBWpU/e+KHkxU2Gkkmey9KwE kTS4zup4bsqvdahtR5cZskPZcUGramR1A76PQzoh07UJgOuIvomXP84WjTSC+wx7S/b8 lMguej5VuMy4rAsDRejEvJe87DlUeMOlE9lnM4ONq7YjZCXzJ97srje+cbKrqdjyAcig DMplW5uxp+fLsrjsEtmVoO3dkTnLsckKkycDexuAugw2kqZpVxOc/hWzomNOSvE126ba FLIw== 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 b6-v6si605713plx.805.2018.02.02.09.51.16; Fri, 02 Feb 2018 09:51:31 -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 S1753605AbeBBRtM (ORCPT + 99 others); Fri, 2 Feb 2018 12:49:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39374 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbeBBRNe (ORCPT ); Fri, 2 Feb 2018 12:13:34 -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 B9218F09; Fri, 2 Feb 2018 17:13:32 +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.14 141/156] usb: f_fs: Prevent gadget unbind if it is already unbound Date: Fri, 2 Feb 2018 17:58:42 +0100 Message-Id: <20180202140846.752294613@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@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.14-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 @@ -3704,7 +3704,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();