Skip to content

Commit 8960ba6

Browse files
Paul Zimmermanpopcornmix
Paul Zimmerman
authored andcommitted
usb: dwc_otg: fix memory corruption in dwc_otg driver
[Upstream commit 51b1b64] The move from the staging tree to the main tree exposed a longstanding memory corruption bug in the dwc2 driver. The reordering of the driver initialization caused the dwc2 driver to corrupt the initialization data of the sdhci driver on the Raspberry Pi platform, which made the bug show up. The error is in calling to_usb_device(hsotg->dev), since ->dev is not a member of struct usb_device. The easiest fix is to just remove the offending code, since it is not really needed. Thanks to Stephen Warren for tracking down the cause of this. Reported-by: Andre Heider <[email protected]> Tested-by: Stephen Warren <[email protected]> Signed-off-by: Paul Zimmerman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> [lukas: port from upstream dwc2 to out-of-tree dwc_otg driver] Signed-off-by: Lukas Wunner <[email protected]>
1 parent 9d2ad14 commit 8960ba6

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,25 +1012,11 @@ static void endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
10121012
static void endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
10131013
{
10141014
dwc_irqflags_t flags;
1015-
struct usb_device *udev = NULL;
1016-
int epnum = usb_endpoint_num(&ep->desc);
1017-
int is_out = usb_endpoint_dir_out(&ep->desc);
1018-
int is_control = usb_endpoint_xfer_control(&ep->desc);
10191015
dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd(hcd);
1020-
struct device *dev = DWC_OTG_OS_GETDEV(dwc_otg_hcd->otg_dev->os_dep);
1021-
1022-
if (dev)
1023-
udev = to_usb_device(dev);
1024-
else
1025-
return;
10261016

10271017
DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD EP RESET: Endpoint Num=0x%02d\n", epnum);
10281018

10291019
DWC_SPINLOCK_IRQSAVE(dwc_otg_hcd->lock, &flags);
1030-
usb_settoggle(udev, epnum, is_out, 0);
1031-
if (is_control)
1032-
usb_settoggle(udev, epnum, !is_out, 0);
1033-
10341020
if (ep->hcpriv) {
10351021
dwc_otg_hcd_endpoint_reset(dwc_otg_hcd, ep->hcpriv);
10361022
}

0 commit comments

Comments
 (0)