From 499fcb657afea8d5ee69b0d2ff8901f5167892cb Mon Sep 17 00:00:00 2001 From: Wu Liang feng Date: Thu, 13 Oct 2016 14:08:52 +0800 Subject: [PATCH] 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 --- drivers/usb/dwc3/dwc3-rockchip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.34.1