]> git.hungrycats.org Git - linux/commitdiff
[PATCH] USB: Fix connect/disconnect race
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 9 Dec 2003 09:40:44 +0000 (01:40 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 9 Dec 2003 09:40:44 +0000 (01:40 -0800)
This patch was integrated by you in 2.4 six months ago.  Unfortunately
it never got into 2.5.  Without it you can end up with crashes such
as http://bugs.debian.org/218670

drivers/usb/core/hub.c

index eba7d9fca67a021689a7da65698c8f5f1990425d..d019f21cec371aab58ebd40c372098716a524f48 100644 (file)
@@ -929,7 +929,6 @@ static void hub_port_connect_change(struct usb_hub *hubstate, int port,
                        break;
                }
 
-               hub->children[port] = dev;
                dev->state = USB_STATE_POWERED;
 
                /* Reset the device, and detect its speed */
@@ -982,8 +981,10 @@ static void hub_port_connect_change(struct usb_hub *hubstate, int port,
                dev->dev.parent = dev->parent->dev.parent->parent;
 
                /* Run it through the hoops (find a driver, etc) */
-               if (!usb_new_device(dev, &hub->dev))
+               if (!usb_new_device(dev, &hub->dev)) {
+                       hub->children[port] = dev;
                        goto done;
+               }
 
                /* Free the configuration if there was an error */
                usb_put_dev(dev);
@@ -992,7 +993,6 @@ static void hub_port_connect_change(struct usb_hub *hubstate, int port,
                delay = HUB_LONG_RESET_TIME;
        }
 
-       hub->children[port] = NULL;
        hub_port_disable(hub, port);
 done:
        up(&usb_address0_sem);