From: Wu Liang feng Date: Thu, 13 Oct 2016 06:08:52 +0000 (+0800) Subject: usb: dwc3: rockchip: fix xhci NULL pointer dereference X-Git-Tag: firefly_0821_release~1415 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=499fcb657afea8d5ee69b0d2ff8901f5167892cb;p=firefly-linux-kernel-4.4.55.git usb: dwc3: rockchip: fix xhci NULL pointer dereference If DWC3 works as peripheral only mode, XHCI HCD will not be created and added, so we should only get XHCI HCD in host mode. Change-Id: Iefb02431d6a973050986963bbabe0a943283f4b3 Signed-off-by: Wu Liang feng --- diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c index 8a0303467502..198f67158c33 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -81,7 +81,7 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work) container_of(work, struct dwc3_rockchip, otg_work); struct dwc3 *dwc = rockchip->dwc; struct extcon_dev *edev = rockchip->edev; - struct usb_hcd *hcd = dev_get_drvdata(&dwc->xhci->dev); + struct usb_hcd *hcd; unsigned long flags; int ret; u32 reg; @@ -180,6 +180,8 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work) */ usleep_range(10000, 11000); + hcd = dev_get_drvdata(&dwc->xhci->dev); + if (hcd->state == HC_STATE_HALT) { usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); usb_add_hcd(hcd->shared_hcd, hcd->irq, IRQF_SHARED);