diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-07-16 15:28:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-19 20:46:04 -0400 |
commit | 195af2cce5ff81c4609c7ba585b6698a7771cbfc (patch) | |
tree | d5367fb5a16f6b0403e91d75aa3cc4c4ba05adfd /drivers/usb | |
parent | 69d42a78f935d19384d1f6e4f94b65bb162b36df (diff) |
USB: fix warning caused by autosuspend counter going negative
This patch (as937) fixes a minor bug in the autosuspend usage-counting
code. Each hub's usage counter keeps track of the number of
unsuspended children. However the current driver increments the
counter after registering a new child, by which time the child may
already have been suspended and caused the counter to go negative.
The obvious solution is to increment the counter before registering
the child.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/hub.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index fd74c50b1804..e341a1da517f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -1335,6 +1335,10 @@ int usb_new_device(struct usb_device *udev) | |||
1335 | udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, | 1335 | udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, |
1336 | (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); | 1336 | (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); |
1337 | 1337 | ||
1338 | /* Increment the parent's count of unsuspended children */ | ||
1339 | if (udev->parent) | ||
1340 | usb_autoresume_device(udev->parent); | ||
1341 | |||
1338 | /* Register the device. The device driver is responsible | 1342 | /* Register the device. The device driver is responsible |
1339 | * for adding the device files to sysfs and for configuring | 1343 | * for adding the device files to sysfs and for configuring |
1340 | * the device. | 1344 | * the device. |
@@ -1342,13 +1346,11 @@ int usb_new_device(struct usb_device *udev) | |||
1342 | err = device_add(&udev->dev); | 1346 | err = device_add(&udev->dev); |
1343 | if (err) { | 1347 | if (err) { |
1344 | dev_err(&udev->dev, "can't device_add, error %d\n", err); | 1348 | dev_err(&udev->dev, "can't device_add, error %d\n", err); |
1349 | if (udev->parent) | ||
1350 | usb_autosuspend_device(udev->parent); | ||
1345 | goto fail; | 1351 | goto fail; |
1346 | } | 1352 | } |
1347 | 1353 | ||
1348 | /* Increment the parent's count of unsuspended children */ | ||
1349 | if (udev->parent) | ||
1350 | usb_autoresume_device(udev->parent); | ||
1351 | |||
1352 | exit: | 1354 | exit: |
1353 | return err; | 1355 | return err; |
1354 | 1356 | ||