Skip to content

Commit 51b1b64

Browse files
Paul Zimmermangregkh
Paul Zimmerman
authored andcommitted
usb: dwc2: fix memory corruption in dwc2 driver
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]>
1 parent a23666c commit 51b1b64

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

drivers/usb/dwc2/hcd.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,25 +2565,14 @@ static void _dwc2_hcd_endpoint_reset(struct usb_hcd *hcd,
25652565
struct usb_host_endpoint *ep)
25662566
{
25672567
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
2568-
int is_control = usb_endpoint_xfer_control(&ep->desc);
2569-
int is_out = usb_endpoint_dir_out(&ep->desc);
2570-
int epnum = usb_endpoint_num(&ep->desc);
2571-
struct usb_device *udev;
25722568
unsigned long flags;
25732569

25742570
dev_dbg(hsotg->dev,
25752571
"DWC OTG HCD EP RESET: bEndpointAddress=0x%02x\n",
25762572
ep->desc.bEndpointAddress);
25772573

2578-
udev = to_usb_device(hsotg->dev);
2579-
25802574
spin_lock_irqsave(&hsotg->lock, flags);
2581-
2582-
usb_settoggle(udev, epnum, is_out, 0);
2583-
if (is_control)
2584-
usb_settoggle(udev, epnum, !is_out, 0);
25852575
dwc2_hcd_endpoint_reset(hsotg, ep);
2586-
25872576
spin_unlock_irqrestore(&hsotg->lock, flags);
25882577
}
25892578

0 commit comments

Comments
 (0)