Received: by 10.223.176.5 with SMTP id f5csp1001351wra; Fri, 2 Feb 2018 09:30:21 -0800 (PST) X-Google-Smtp-Source: AH8x227q1F/5+IofBJ5DUDz9/MsPPo3j/PtJwTDIDNRSZJJjh2LEWNAEk1TH9xWHWkPunyvE96R5 X-Received: by 10.101.90.71 with SMTP id z7mr32043558pgs.15.1517592621686; Fri, 02 Feb 2018 09:30:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592621; cv=none; d=google.com; s=arc-20160816; b=T8V539Y6C3jiTRFjSOJ041/ssg1cJ3MU5YV4Kyvu1shbCHBFSd9+xX9Wn/ZnMocAo9 EiHuK5GM7Z9CsvzfqNL1Bq9zEUA65EG9TIJ2Dcvxbj9Qz0zNylSkLblGaE/8t3dSbOlk 82pGTUaHWmvrKa1lCNUcjYcrJpEYXyxLzIhs3BiP7qKj7cq3a6CFG8q4io9TGf0IPPdD 6FmU76A2IT+Ic/4HpwvMT49GnZl0B6Tc/wyXbJ7cCTjeMMJK/N92wB+RH15iEhRomNGn Ps1eloY0pgsoKUYxgyUFK59Cps9+tusNKrrDgtMEDQ5DQoF6bFlv6PkKXLeA/Ty2cJn3 dE2w== 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=rlDHt6c3vED0/tpuHjvx7bqhkNEemyrr6318DG8omVw=; b=RwiHN3VBnT2voj37EBR7FOFjAMrvkyfZwoPjuCJqxsAqQW/jnyIboCaiEoYBlQ0UVi qSHBp3k96tDOXk2jBKVqVpeRNXKESyI0nDINdZo8XSpzMNshQFP8F5DM2YPs5YHDT1Hn xqTCBSdId2+XupaFLiEOce4QvAanm/hALCqiuWfvHII5iUgpFzHag7it11DH4YkTtYvK 5vhi1rF3TqX3yMZfKitEOAerO2Y9AKj6zmzI7xpuA9D5AttTD5QCoDGOs9N0u5OuJv7g ZeCZLXrYsUeBP47AeGU/Pkx+cyBCrbmtWSxZfyEHoYO7AOvm3Moz1KBUZ7gVaJvwajzG N6mg== 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 t6-v6si268290plr.777.2018.02.02.09.30.06; Fri, 02 Feb 2018 09:30:21 -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 S1754185AbeBBR1t (ORCPT + 99 others); Fri, 2 Feb 2018 12:27:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40962 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753242AbeBBRQQ (ORCPT ); Fri, 2 Feb 2018 12:16:16 -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 3B751F27; Fri, 2 Feb 2018 17:16:15 +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.15 39/55] usb: f_fs: Prevent gadget unbind if it is already unbound Date: Fri, 2 Feb 2018 17:58:57 +0100 Message-Id: <20180202140829.995927541@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140826.117602411@linuxfoundation.org> References: <20180202140826.117602411@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.15-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 @@ -3700,7 +3700,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();