usb: dwc2: Fix use after free in debug code
Subsystems (3)
PATCH 1/1 usb: dwc2: Fix use after free in debug code
We're not allowed to dereference "urb" after calling usb_hcd_giveback_urb() so save the urb->status ahead of time.
Fixes 7359d482eb4d ("staging: HCD files for the DWC2 driver")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/usb/dwc2/hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/dwc2/hcd.c +3 -1
@@ -4804,6 +4804,7 @@ static int _dwc2_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,struct dwc2_hsotg *hsotg =dwc2_hcd_to_hsotg (hcd);int rc;unsigned long flags; +int urb_status;dev_dbg (hsotg->dev,"DWC OTG HCD URB Dequeue\n" );dwc2_dump_urb_info (hcd, urb,"urb_dequeue" );
@@ -4828,11 +4829,12 @@ static int _dwc2_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,/* Higher layer software sets URB status */ spin_unlock (&hsotg->lock); + urb_status = urb->status;usb_hcd_giveback_urb (hcd, urb, status);spin_lock (&hsotg->lock);dev_dbg (hsotg->dev,"Called usb_hcd_giveback_urb()\n" ); -dev_dbg (hsotg->dev," urb->status = %d\n" , urb->status); +dev_dbg (hsotg->dev," urb->status = %d\n" , urb_status); out:spin_unlock_irqrestore (&hsotg->lock, flags);
Signature · 1 line
2.53.0