From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59D33C2D0D3 for ; Fri, 20 Dec 2019 14:37:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 30F3E24689 for ; Fri, 20 Dec 2019 14:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576852679; bh=ypZKQYyvYWF6PX/rd/ElPTo5DDilecVzz+PAaPIOE8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=L3rD4nunygiHv1PYL+IIEcMY1OLgRH19qwfLFHdItlAs+3sCpOUtYxZR3x0wOR114 SRWca2KFV4KwD2KBM3F0Rskpr/a2LxX4lkuNVD02HJx+9CPttOlS3uANPAYZsUPq2k kU9ipGIUSSzpQuDGStHl3PlctNa1QU+rFmsxALwQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728352AbfLTOh5 (ORCPT ); Fri, 20 Dec 2019 09:37:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:42086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbfLTOh5 (ORCPT ); Fri, 20 Dec 2019 09:37:57 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9644B24682; Fri, 20 Dec 2019 14:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576852676; bh=ypZKQYyvYWF6PX/rd/ElPTo5DDilecVzz+PAaPIOE8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AH3o8o99WSvNNHFWUyCOimUh1pAUZo6jIbiLo3nT2BI+YQTnJyIbRMitcSg29QE27 dIau+b/XmXM8AEljKKkUxfzlTCCORAFjW1aFgyLgtze2wZWC/n3oeftGJyz9acUJ+C 3q3OzhR9O4ZqykNqxKlejuTS7NHxqGmZ/zMiGHLA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: EJ Hsu , Peter Chen , Felipe Balbi , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 11/19] usb: gadget: fix wrong endpoint desc Date: Fri, 20 Dec 2019 09:37:32 -0500 Message-Id: <20191220143741.10220-11-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220143741.10220-1-sashal@kernel.org> References: <20191220143741.10220-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: EJ Hsu [ Upstream commit e5b5da96da50ef30abb39cb9f694e99366404d24 ] Gadget driver should always use config_ep_by_speed() to initialize usb_ep struct according to usb device's operating speed. Otherwise, usb_ep struct may be wrong if usb devcie's operating speed is changed. The key point in this patch is that we want to make sure the desc pointer in usb_ep struct will be set to NULL when gadget is disconnected. This will force it to call config_ep_by_speed() to correctly initialize usb_ep struct based on the new operating speed when gadget is re-connected later. Reviewed-by: Peter Chen Signed-off-by: EJ Hsu Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_ecm.c | 6 +++++- drivers/usb/gadget/function/f_rndis.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index 4c488d15b6f6e..dc99ed94f03d2 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -625,8 +625,12 @@ static void ecm_disable(struct usb_function *f) DBG(cdev, "ecm deactivated\n"); - if (ecm->port.in_ep->enabled) + if (ecm->port.in_ep->enabled) { gether_disconnect(&ecm->port); + } else { + ecm->port.in_ep->desc = NULL; + ecm->port.out_ep->desc = NULL; + } usb_ep_disable(ecm->notify); ecm->notify->desc = NULL; diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index c7c5b3ce1d988..2bde68f5d2463 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c @@ -622,6 +622,7 @@ static void rndis_disable(struct usb_function *f) gether_disconnect(&rndis->port); usb_ep_disable(rndis->notify); + rndis->notify->desc = NULL; } /*-------------------------------------------------------------------------*/ -- 2.20.1