usb: xhci: Fix panic if disconnect
[pandora-kernel.git] / drivers / usb / host / xhci-hub.c
index 353fe60..13bb316 100644 (file)
@@ -278,6 +278,9 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
 
        ret = 0;
        virt_dev = xhci->devs[slot_id];
+       if (!virt_dev)
+               return -ENODEV;
+
        cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO);
        if (!cmd) {
                xhci_dbg(xhci, "Couldn't allocate command structure.\n");
@@ -595,7 +598,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        status |= USB_PORT_STAT_C_RESET << 16;
                /* USB3.0 only */
                if (hcd->speed == HCD_USB3) {
-                       if ((temp & PORT_PLC))
+                       /* Port link change with port in resume state should not be
+                        * reported to usbcore, as this is an internal state to be
+                        * handled by xhci driver. Reporting PLC to usbcore may
+                        * cause usbcore clearing PLC first and port change event
+                        * irq won't be generated.
+                        */
+                       if ((temp & PORT_PLC) &&
+                               (temp & PORT_PLS_MASK) != XDEV_RESUME)
                                status |= USB_PORT_STAT_C_LINK_STATE << 16;
                        if ((temp & PORT_WRC))
                                status |= USB_PORT_STAT_C_BH_RESET << 16;