From 08bceb43a596101b03501cebd1e6de166e846393 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 9 Dec 2003 01:40:44 -0800 Subject: [PATCH] [PATCH] USB: Fix connect/disconnect race 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index eba7d9fca67a0..d019f21cec371 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -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); -- 2.53.0