usb: dwc3: rockchip: fix otg plug out error before resume
authorMeng Dongyang <daniel.meng@rock-chips.com>
Fri, 7 Oct 2016 05:50:59 +0000 (13:50 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 13 Oct 2016 02:22:27 +0000 (10:22 +0800)
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 <daniel.meng@rock-chips.com>
drivers/usb/dwc3/dwc3-rockchip.c

index 03cea80d93f3b0e669b40cfe1e1b96fc9aa4ac6c..8a03034675025242f6e1bc886cbf9498ecd5f588 100644 (file)
@@ -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);