Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3312595pxf; Mon, 15 Mar 2021 06:57:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNAfGUgO6iPTg9kYaOldOI57Y4pgh6GIay2q+SB/zx6WyJMdF/pGVnsxI9THTIoUVWg4tY X-Received: by 2002:aa7:db15:: with SMTP id t21mr30159093eds.145.1615816665720; Mon, 15 Mar 2021 06:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816665; cv=none; d=google.com; s=arc-20160816; b=RkTutSiV/VLyM8gmE8aYNW4U5yEeiLY+PO7XkgrqnYV6Cjc01ayDyYcI4M/e1/ShEU ZG0lDEeZ6PsvokKvq0eBEDzi2Avnk3cVJ7OzJhBRjXjNovmg24w4hbvcItqzckDrp3KI 1PvxrgYQ5zWGyPzhV4ImALh+GDX59sSbr8urrtWl6xUWkLVCl1Tdsx5pU3uI834j2xJG RDlg9kK5LbXDibHJBOxoYg+1VdCFXz+AuOGoyZUoBDNOG78z0s3a0AaLdyAcYcW1Q5xi H+1GhQ+YjICmikBPlF67TDf+ii0xLbPBWqklPzW8tiYEpjVWfWITiSritOmioCSO6Dsa JX+w== 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=N9GysOgHrdijDs0tjNUx1THQrM8vQmMeT3+MRWpUu0ZNhtmZoNSzF1gs488BTylHL3 Af1BOdDqsM3WxeoNwv4M7fkJxYjLubFHgWA0w68qHK9IGcnq0Ya13gwfY7Oif130YMRl rJ6yK3jKs99IK0O7ji7LiudtC8HFx/tQI7iSOzMjcEQkT/40AZN3fIrArxQtVcvxq1k9 6uAyxzGUb4NxDnNixwRQD2Rcmc8R45YFZ6Ex47eTcxHgeJvXXc2xDm5qIkslCbidlP85 fLhwG8PME2gcFLxIil9xBUMb5GKLoXdokRWrPtNaDcclHNWb2lE0pZ1auv0RXvn3pbTv qSuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SlWbzlcR; 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 i25si3060087eje.58.2021.03.15.06.57.22; Mon, 15 Mar 2021 06:57:45 -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=SlWbzlcR; 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 S231935AbhCON43 (ORCPT + 99 others); Mon, 15 Mar 2021 09:56:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:57066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230509AbhCONxt (ORCPT ); Mon, 15 Mar 2021 09:53:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 752F864EEA; Mon, 15 Mar 2021 13:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816428; bh=I5/Ju2sqpmZF9GUUl8cG9iEELjgWoaYlwhzX40Zzz+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlWbzlcRsGVTzX6T5/Nb0PQmxxQA+hYOwl/0cgXyKwXIq/lgYyTt1LBeI22qA+wz6 1Rhq94H7ymdDQ3KfjIvrEKSBJ1UKtjM0bTs6h56LvJSIVxJZXUToHTOfwIFYv9Jkax xfGpS2Rq5UgnNNWxcOBYufSp/iHfjAbJVT7PKEtI= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH 4.9 33/78] usb: renesas_usbhs: Clear PIPECFG for re-enabling pipe with other EPNUM Date: Mon, 15 Mar 2021 14:51:56 +0100 Message-Id: <20210315135213.158120262@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135212.060847074@linuxfoundation.org> References: <20210315135212.060847074@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); }