From: Meng Dongyang Date: Fri, 7 Oct 2016 05:50:59 +0000 (+0800) Subject: usb: dwc3: rockchip: fix otg plug out error before resume X-Git-Tag: firefly_0821_release~1419 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ccc954ee9f8859569fe16cc17b598fbfece07ae8;p=firefly-linux-kernel-4.4.55.git 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 --- 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);