Skip to content

Commit

Permalink
USB: fix warning caused by autosuspend counter going negative
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jul 20, 2007
1 parent 69d42a7 commit 195af2c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,20 +1335,22 @@ int usb_new_device(struct usb_device *udev)
udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
(((udev->bus->busnum-1) * 128) + (udev->devnum-1)));

/* Increment the parent's count of unsuspended children */
if (udev->parent)
usb_autoresume_device(udev->parent);

/* Register the device. The device driver is responsible
* for adding the device files to sysfs and for configuring
* the device.
*/
err = device_add(&udev->dev);
if (err) {
dev_err(&udev->dev, "can't device_add, error %d\n", err);
if (udev->parent)
usb_autosuspend_device(udev->parent);
goto fail;
}

/* Increment the parent's count of unsuspended children */
if (udev->parent)
usb_autoresume_device(udev->parent);

exit:
return err;

Expand Down

0 comments on commit 195af2c

Please sign in to comment.