]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: Prepare for refactoring by adding extra udev checks.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Fri, 8 Mar 2013 00:23:34 +0000 (16:23 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Mar 2013 18:26:37 +0000 (11:26 -0700)
[This is upstream commit 2d4fa940f99663c82ba55b2244638833b388e4e2.
It needs to be backported to kernels as old as 3.2, because it fixes the
buggy commit 65bdac5effd15d6af619b3b7218627ef4d84ed6a "USB: Handle warm
reset failure on empty port."]

The next patch will refactor the hub port code to rip out the recursive
call to hub_port_reset on a failed hot reset.  In preparation for that,
make sure all code paths can deal with being called with a NULL udev.
The usb_device will not be valid if warm reset was issued because a port
transitioned to the Inactive or Compliance Mode on a device connect.

This patch should have no effect on current behavior.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hub.c

index f9de94eb3c40e6b4f35f1bba14afa7c957869ac8..3ecd6638325f92ae12ed3cc0a4f501c0447a225c 100644 (file)
@@ -2584,6 +2584,9 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
                                return -ENOTCONN;
 
                        if ((portstatus & USB_PORT_STAT_ENABLE)) {
+                               if (!udev)
+                                       return 0;
+
                                if (hub_is_wusb(hub))
                                        udev->speed = USB_SPEED_WIRELESS;
                                else if (hub_is_superspeed(hub->hdev))
@@ -2627,13 +2630,15 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1,
                        struct usb_hcd *hcd;
                        /* TRSTRCY = 10 ms; plus some extra */
                        msleep(10 + 40);
-                       update_devnum(udev, 0);
-                       hcd = bus_to_hcd(udev->bus);
-                       /* The xHC may think the device is already reset,
-                        * so ignore the status.
-                        */
-                       if (hcd->driver->reset_device)
-                               hcd->driver->reset_device(hcd, udev);
+                       if (udev) {
+                               update_devnum(udev, 0);
+                               hcd = bus_to_hcd(udev->bus);
+                               /* The xHC may think the device is already
+                                * reset, so ignore the status.
+                                */
+                               if (hcd->driver->reset_device)
+                                       hcd->driver->reset_device(hcd, udev);
+                       }
                }
                /* FALL THROUGH */
        case -ENOTCONN:
@@ -2647,7 +2652,7 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1,
                        clear_port_feature(hub->hdev, port1,
                                        USB_PORT_FEAT_C_PORT_LINK_STATE);
                }
-               if (!warm)
+               if (!warm && udev)
                        usb_set_device_state(udev, *status
                                        ? USB_STATE_NOTATTACHED
                                        : USB_STATE_DEFAULT);