From ccc954ee9f8859569fe16cc17b598fbfece07ae8 Mon Sep 17 00:00:00 2001 From: Meng Dongyang Date: Fri, 7 Oct 2016 13:50:59 +0800 Subject: [PATCH] usb: dwc3: rockchip: fix otg plug out error before resume ID dig disconnect interrupt will happen and notify dwc3 controller to remove hcd as soon as resume, and release root hub, but the hcd has not resume, so there is a logic error and it may result in NULL pointer, this patch forbid remove hcd when the state of hcd is suspend. Change-Id: Ia5673848a23528cd053d75910c0fdbddf0927a40 Signed-off-by: Meng Dongyang --- drivers/usb/dwc3/dwc3-rockchip.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c index 03cea80d93f3..8a0303467502 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -210,6 +210,11 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work) DWC3_GCTL_PRTCAP(reg) == DWC3_GCTL_PRTCAP_OTG) { hcd = dev_get_drvdata(&dwc->xhci->dev); + if (hcd->state == HC_STATE_SUSPENDED) { + dev_dbg(rockchip->dev, "USB suspended\n"); + goto out; + } + if (hcd->state != HC_STATE_HALT) { usb_remove_hcd(hcd->shared_hcd); usb_remove_hcd(hcd); -- 2.34.1