From patchwork Mon Feb 4 18:04:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guido Kiener X-Patchwork-Id: 10796165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E86B13B4 for ; Mon, 4 Feb 2019 17:10:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F11AE2BD5C for ; Mon, 4 Feb 2019 17:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5D442BDB5; Mon, 4 Feb 2019 17:10:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91D742BD5C for ; Mon, 4 Feb 2019 17:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730747AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mr08.mx01.tldhost.de ([84.19.26.246]:35430 "EHLO mr08.mx01.tldhost.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728169AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mx01.tldhost.de (localhost [127.0.0.1]) by mx01.tldhost.de (Postfix) with ESMTP id DD02A121122 for ; Mon, 4 Feb 2019 18:05:28 +0100 (CET) Received: by mx01.tldhost.de (Postfix, from userid 1001) id CD9EC120F81; Mon, 4 Feb 2019 18:05:28 +0100 (CET) Received: from server12.tldhost.de (server12.tldhost.de [84.19.26.112]) by mx01.tldhost.de (Postfix) with ESMTPS id C9A04120F81; Mon, 4 Feb 2019 18:05:26 +0100 (CET) From: Guido Kiener To: Felipe Balbi , linux-usb@vger.kernel.org, guido.kiener@rohde-schwarz.com Subject: [PATCH 1/3] udc: net2280: Fix net2280_disable Date: Mon, 4 Feb 2019 19:04:20 +0100 Message-Id: <20190204180422.5095-1-guido@kiener-muenchen.de> X-PPP-Message-ID: <20190204170527.15170.16330@server12.tldhost.de> X-PPP-Vhost: kiener-muenchen.de X-POWERED-BY: TLDHost.de - AV:CLEAN SPAM:OK Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Guido Kiener A reset e.g. calling ep_reset_338x() can happen while endpoints are enabled. The ep_reset_338x() sets ep->desc = NULL to mark endpoint being invalid. A subsequent call of net2280_disable will fail and return -EINVAL to parent function usb_ep_disable(), which will fail, too, and do not set the member ep->enabled = false. See: https://elixir.bootlin.com/linux/v5.0-rc5/source/drivers/usb/gadget/udc/core.c#L139 This fix ignores dp->desc and allows net2280_disable() to succeed. Subsequent calls to usb_ep_enable()/usb_ep_disable() succeeds. Signed-off-by: Guido Kiener Acked-by: Alan Stern --- drivers/usb/gadget/udc/net2280.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index e7dae5379e04..7154f00dea40 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -516,8 +516,8 @@ static int net2280_disable(struct usb_ep *_ep) unsigned long flags; ep = container_of(_ep, struct net2280_ep, ep); - if (!_ep || !ep->desc || _ep->name == ep0name) { - pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep); + if (!_ep || _ep->name == ep0name) { + pr_err("%s: Invalid ep=%p\n", __func__, _ep); return -EINVAL; } spin_lock_irqsave(&ep->dev->lock, flags);