Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2749923ybc; Wed, 20 Nov 2019 20:23:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwysQkVZaqMGaeEnSp4lfD3h2qjK0OJX3o7QCh6UhwWfTAv+yts7PKU/eUKjbVXlIpDARWu X-Received: by 2002:a17:906:a396:: with SMTP id k22mr10720431ejz.66.1574310220842; Wed, 20 Nov 2019 20:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574310220; cv=none; d=google.com; s=arc-20160816; b=sPel5KFSMqk++kGjeUtJdwfLunIHGWzRLcwIbdx0EqZyhVtJLatioRJEhe2iRHVFS/ DSdY++gsokfU0lUCXmIiC96Q49c+Z3IoPozartB2heIN+P4qiwdZjv7AlEJPO8JsY6jF axNWyxPXY8vHQqYTCzdMRyJvDQASVlDJDAZO3gtZySOaMtDlooPO0MDFi0iH1ej4hanj GMDqGv/hL26BpX3zFjmgYoOxOpZ6SiK/UuaPXHcotlNgJriL3g1GH83/+OZtpIVwK3uK 5sDWd42/xT+7HpmwFi00wvJJ1HglbGzYipzg1ao6xbNZg5pJJvsx1mYEg+0cax/3vWFu Elag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:dkim-signature:mime-version:message-id :date:subject:cc:from; bh=EL2BQGDO8oGg4dJi/hYdF+5hmA52O9yZOuCrfBec8eY=; b=gmOI6ErivHuxYmYxHneQ0ji9477ntyCIa2vJmg4kHLzjSu31tCLJChnmRxYsBo9kX5 hV8whfrAu3rLBzkthGY3fmKbpK77is70T6SkfH9/K/1YqOKwqb/qN+hNUUkeCKp1QeVh ts84ZVDthdFYk1I2VnSsD6AvfNvCl+L7LbW8UxTvWXIH7QbU7S25ZZbWvQqLlJzrRsga wswi9DrECQirIK89uOesMoCg2VfpiDhhyHivymFnhpApVyY2JaUaTEueq/Pi/iuC9qo9 iwH/BlSCzu1f5eddJmBM0weKunhsjDc11V27N/o4HBu937FthtMK2R/10FMYSUWyQSA3 rOWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b="TAGAg/gA"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si822399ejx.212.2019.11.20.20.23.17; Wed, 20 Nov 2019 20:23:40 -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; dkim=fail header.i=@nvidia.com header.s=n1 header.b="TAGAg/gA"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726358AbfKUETn (ORCPT + 99 others); Wed, 20 Nov 2019 23:19:43 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:15600 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfKUETm (ORCPT ); Wed, 20 Nov 2019 23:19:42 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 20 Nov 2019 20:19:43 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 20 Nov 2019 20:19:42 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 20 Nov 2019 20:19:42 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 21 Nov 2019 04:19:41 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 21 Nov 2019 04:19:40 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 21 Nov 2019 04:19:40 +0000 Received: from henryl-tu10x.nvidia.com (Not Verified[10.19.109.104]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 20 Nov 2019 20:19:40 -0800 From: Henry Lin CC: Henry Lin , Felipe Balbi , "Greg Kroah-Hartman" , Romain Izard , , Subject: [PATCH] usb: gadget: f_ncm: fix wrong usb_ep Date: Thu, 21 Nov 2019 12:18:57 +0800 Message-ID: <20191121041858.15746-1-henryl@nvidia.com> X-Mailer: git-send-email 2.17.1 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1574309983; bh=EL2BQGDO8oGg4dJi/hYdF+5hmA52O9yZOuCrfBec8eY=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=TAGAg/gA4c2DhV7MT/+D/f8eACascD0i3gQ8mFFxxInznvJlDX7f++LfCCzosojTZ pmXT5/qGYOoVr11ba333LTA9LvTvfDkzy3dNC6ycwQGAFVsSHnV55u79pcyiOnIlJG gE+gssDA2CwR4vd40IJ/LM2zeVMimngRnqEGGJpcn7ceIxupEghjGzwHWSnb2XhvMF 8t85ctBxY291ixwMGGsZX0urtCFdNVmNPt30LU4yE0E/PiyOeT4a97v9LdPbsL9lZC T8ri4PnX7UlJYTL1Jmgk7GexpUUYsoLA8s7Xird1gqH1CfTNILVNdsfhV1d4V37tot hCD4tepLrLwQw== To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Henry Lin --- drivers/usb/gadget/function/f_ncm.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index 2d6e76e4cffa..420b9c96f2fe 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -870,11 +870,10 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) DBG(cdev, "reset ncm control %d\n", intf); usb_ep_disable(ncm->notify); - if (!(ncm->notify->desc)) { - DBG(cdev, "init ncm ctrl %d\n", intf); - if (config_ep_by_speed(cdev->gadget, f, ncm->notify)) - goto fail; - } + DBG(cdev, "init ncm ctrl %d\n", intf); + if (config_ep_by_speed(cdev->gadget, f, ncm->notify)) + goto fail; + usb_ep_enable(ncm->notify); /* Data interface has two altsettings, 0 and 1 */ @@ -897,17 +896,14 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) if (alt == 1) { struct net_device *net; - if (!ncm->port.in_ep->desc || - !ncm->port.out_ep->desc) { - DBG(cdev, "init ncm\n"); - if (config_ep_by_speed(cdev->gadget, f, - ncm->port.in_ep) || - config_ep_by_speed(cdev->gadget, f, - ncm->port.out_ep)) { - ncm->port.in_ep->desc = NULL; - ncm->port.out_ep->desc = NULL; - goto fail; - } + DBG(cdev, "init ncm\n"); + if (config_ep_by_speed(cdev->gadget, f, + ncm->port.in_ep) || + config_ep_by_speed(cdev->gadget, f, + ncm->port.out_ep)) { + ncm->port.in_ep->desc = NULL; + ncm->port.out_ep->desc = NULL; + goto fail; } /* TODO */ -- 2.17.1