Skip to content

Commit

Permalink
usb: gadget: fix wrong endpoint desc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
EJ Hsu authored and Felipe Balbi committed Dec 10, 2019
1 parent 2d7b78f commit e5b5da9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/usb/gadget/function/f_ecm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/gadget/function/f_rndis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*-------------------------------------------------------------------------*/
Expand Down

0 comments on commit e5b5da9

Please sign in to comment.