Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526440pxf; Mon, 15 Mar 2021 11:31:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+qp4tKqge5FfYbA7cY9zGONfN5RZuO2qcr64x02ML2NR2en8VLVUYqas/n7vwhaZ/+WZr X-Received: by 2002:a17:906:f6ce:: with SMTP id jo14mr25531463ejb.476.1615833078850; Mon, 15 Mar 2021 11:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833078; cv=none; d=google.com; s=arc-20160816; b=zFvmgzOHs2rdbRQdOQ1DYHHu9lCzSxDyGq5vkKhnzIEcaC1dX5I5Ql7MkWxiVCQIl7 UIAKdcZMM0xEHQ2ZzMl6nx344/xeh8vV0iaB1WJT7cTXv8rcmUOhfbxthi8d8IdQbCF/ XW/NJgDaSWnok4iMcNdugiJq8kAYsbsyvlc3Y6RHTI0f1GjzvK/3bWY8BlwOCkayV26w ei4+ZWELVXPWcRI+WfECp/UnfncLdELGLAnNQMnBA/FZz98feX/RJe47/gzvONUNtQUB rph/xeagcVo+5XbE72h2Cm8kbQHBcbvuW9BRkJmCrsou4TSFTGUX25ZswzqnpXI15TBF tyZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7sXxXxWoCMBLZCxwYIHk2FWhafYb6bN1Jxo/G0k8ENs=; b=eDAHZNjuezrVGv2CEdAbYz/96sDhuSFBAahkLWMfJIslWyQk7JzIZ289D/KJg8qJEo AD9Wtns+3FHGCe+clneFy2+p0/2u534VkHvNlGP85J+Gb4TsOZuf3fNyOPRjF6DQBruf kE+adGbvPw/jZbO1O5PJeZ7EWy3H0VRQImeM4fQBumsasEU6TmzAqWeKhSSDtZUZvro9 TRxAUDZnYshRj76oNVhN8WJo/w1o+WtZbXWz2FpXRdgepWcH17/VBwlX+LGegfC3V2yF IuNlKKyw0qUtbWLy2P/Mmpfhf0r0rAyErHIaAElyWRDj8IcGMjP0lXgmGE8ZYg+RVQHB Z9Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AtbVm58q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si11835053edx.88.2021.03.15.11.30.56; Mon, 15 Mar 2021 11:31:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AtbVm58q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240798AbhCOOi0 (ORCPT + 99 others); Mon, 15 Mar 2021 10:38:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:48792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233563AbhCOOCC (ORCPT ); Mon, 15 Mar 2021 10:02:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7CC8664E83; Mon, 15 Mar 2021 14:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816921; bh=I5/Ju2sqpmZF9GUUl8cG9iEELjgWoaYlwhzX40Zzz+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtbVm58qlo5v4PGxRQZYAsJxAJUDTrX96PIcvb9zHmk+H8Mxh8MkCUPWDymllmpMy 1ANeCHYvaah4nubPxIMMWqc7FYTU2mfdMUFrvzr20lOepwt776oWtf6CmMjTw0V8fk 4RCp6+HJ44nNJ+fK6d4jDbYbUJMHmfEKost1lVSk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH 5.11 203/306] usb: renesas_usbhs: Clear PIPECFG for re-enabling pipe with other EPNUM Date: Mon, 15 Mar 2021 14:54:26 +0100 Message-Id: <20210315135514.497948719@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Yoshihiro Shimoda commit b1d25e6ee57c2605845595b6c61340d734253eb3 upstream. According to the datasheet, this controller has a restriction which "set an endpoint number so that combinations of the DIR bit and the EPNUM bits do not overlap.". However, since the udc core driver is possible to assign a bulk pipe as an interrupt endpoint, an endpoint number may not match the pipe number. After that, when user rebinds another gadget driver, this driver broke the restriction because the driver didn't clear any configuration in usb_ep_disable(). Example: # modprobe g_ncm Then, EP3 = pipe 3, EP4 = pipe 4, EP5 = pipe 6 # rmmod g_ncm # modprobe g_hid Then, EP3 = pipe 6, EP4 = pipe 7. So, pipe 3 and pipe 6 are set as EP3. So, clear PIPECFG register in usbhs_pipe_free(). Fixes: dfb87b8bfe09 ("usb: renesas_usbhs: gadget: fix re-enabling pipe without re-connecting") Cc: stable Signed-off-by: Yoshihiro Shimoda Link: https://lore.kernel.org/r/1615168538-26101-1-git-send-email-yoshihiro.shimoda.uh@renesas.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/pipe.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c @@ -746,6 +746,8 @@ struct usbhs_pipe *usbhs_pipe_malloc(str void usbhs_pipe_free(struct usbhs_pipe *pipe) { + usbhsp_pipe_select(pipe); + usbhsp_pipe_cfg_set(pipe, 0xFFFF, 0); usbhsp_put_pipe(pipe); }