linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: EJ Hsu <ejh@nvidia.com>, Peter Chen <peter.chen@nxp.com>,
	Felipe Balbi <balbi@kernel.org>, Sasha Levin <sashal@kernel.org>,
	linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 39/52] usb: gadget: fix wrong endpoint desc
Date: Fri, 20 Dec 2019 09:29:41 -0500	[thread overview]
Message-ID: <20191220142954.9500-39-sashal@kernel.org> (raw)
In-Reply-To: <20191220142954.9500-1-sashal@kernel.org>

From: EJ Hsu <ejh@nvidia.com>

[ 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 <peter.chen@nxp.com>
Signed-off-by: EJ Hsu <ejh@nvidia.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 6ce044008cf6c..460d5d7c984f5 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -621,8 +621,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 d48df36622b74..0d8e4a364ca6e 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -618,6 +618,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


  parent reply	other threads:[~2019-12-20 14:33 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 14:29 [PATCH AUTOSEL 5.4 01/52] drm/mcde: dsi: Fix invalid pointer dereference if panel cannot be found Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 02/52] nvme_fc: add module to ops template to allow module references Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 03/52] nvme-fc: fix double-free scenarios on hw queues Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 04/52] drm/amdgpu: add check before enabling/disabling broadcast mode Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 05/52] drm/amdgpu: add header line for power profile on Arcturus Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 06/52] drm/amdgpu: add cache flush workaround to gfx8 emit_fence Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 07/52] drm/amd/display: Map DSC resources 1-to-1 if numbers of OPPs and DSCs are equal Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 08/52] drm/amd/display: Fixed kernel panic when booting with DP-to-HDMI dongle Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 09/52] drm/amd/display: Change the delay time before enabling FEC Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 10/52] drm/amd/display: Reset steer fifo before unblanking the stream Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 11/52] drm/amd/display: update dispclk and dppclk vco frequency Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 12/52] nvme/pci: Fix write and poll queue types Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 13/52] nvme/pci: Fix read queue count Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 14/52] iio: st_accel: Fix unused variable warning Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 15/52] iio: adc: max9611: Fix too short conversion time delay Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 16/52] PM / devfreq: Fix devfreq_notifier_call returning errno Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 17/52] PM / devfreq: Set scaling_max_freq to max on OPP notifier error Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 18/52] PM / devfreq: Don't fail devfreq_dev_release if not in list Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 19/52] afs: Fix afs_find_server lookups for ipv4 peers Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 20/52] afs: Fix SELinux setting security label on /afs Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 21/52] RDMA/cma: add missed unregister_pernet_subsys in init failure Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 22/52] rxe: correctly calculate iCRC for unaligned payloads Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 23/52] scsi: lpfc: Fix memory leak on lpfc_bsg_write_ebuf_set func Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 24/52] scsi: qla2xxx: Use explicit LOGO in target mode Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 25/52] scsi: qla2xxx: Drop superfluous INIT_WORK of del_work Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 26/52] scsi: qla2xxx: Don't call qlt_async_event twice Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 27/52] scsi: qla2xxx: Fix PLOGI payload and ELS IOCB dump length Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 28/52] scsi: qla2xxx: Configure local loop for N2N target Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 29/52] scsi: qla2xxx: Send Notify ACK after N2N PLOGI Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 30/52] scsi: qla2xxx: Don't defer relogin unconditonally Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 31/52] scsi: qla2xxx: Ignore PORT UPDATE after N2N PLOGI Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 32/52] scsi: iscsi: qla4xxx: fix double free in probe Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 33/52] scsi: libsas: stop discovering if oob mode is disconnected Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 34/52] scsi: iscsi: Avoid potential deadlock in iscsi_if_rx func Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 35/52] staging/wlan-ng: add CRC32 dependency in Kconfig Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 36/52] drm/nouveau: Move the declaration of struct nouveau_conn_atom up a bit Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 37/52] drm/nouveau: Fix drm-core using atomic code-paths on pre-nv50 hardware Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 38/52] drm/nouveau/kms/nv50-: fix panel scaling Sasha Levin
2019-12-20 14:29 ` Sasha Levin [this message]
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 40/52] net: make socket read/write_iter() honor IOCB_NOWAIT Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 41/52] afs: Fix mountpoint parsing Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 42/52] afs: Fix creation calls in the dynamic root to fail with EOPNOTSUPP Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 43/52] raid5: need to set STRIPE_HANDLE for batch head Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 44/52] md: raid1: check rdev before reference in raid1_sync_request func Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 45/52] s390/cpum_sf: Adjust sampling interval to avoid hitting sample limits Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 46/52] s390/cpum_sf: Avoid SBD overflow condition in irq handler Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 47/52] RDMA/counter: Prevent auto-binding a QP which are not tracked with res Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 48/52] IB/mlx4: Follow mirror sequence of device add during device removal Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 49/52] IB/mlx5: Fix steering rule of drop and count Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 50/52] xen-blkback: prevent premature module unload Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 51/52] xen/balloon: fix ballooned page accounting without hotplug enabled Sasha Levin
2019-12-20 14:29 ` [PATCH AUTOSEL 5.4 52/52] PM / hibernate: memory_bm_find_bit(): Tighten node optimisation Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191220142954.9500-39-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=balbi@kernel.org \
    --cc=ejh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@nxp.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).