Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d5b54cf authored by EJ Hsu's avatar EJ Hsu Committed by Greg Kroah-Hartman
Browse files

usb: gadget: fix wrong endpoint desc



[ 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: default avatarPeter Chen <peter.chen@nxp.com>
Signed-off-by: default avatarEJ Hsu <ejh@nvidia.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 60dee18d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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;
}

/*-------------------------------------------------------------------------*/