Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
195af2cc 69d42a78

+6 -4
+6 -4
drivers/usb/core/hub.c
··· 1335 1335 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, 1336 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 1342 /* Register the device. The device driver is responsible 1339 1343 * for adding the device files to sysfs and for configuring 1340 1344 * the device. ··· 1346 1342 err = device_add(&udev->dev); 1347 1343 if (err) { 1348 1344 dev_err(&udev->dev, "can't device_add, error %d\n", err); 1345 + if (udev->parent) 1346 + usb_autosuspend_device(udev->parent); 1349 1347 goto fail; 1350 1348 } 1351 - 1352 - /* Increment the parent's count of unsuspended children */ 1353 - if (udev->parent) 1354 - usb_autoresume_device(udev->parent); 1355 1349 1356 1350 exit: 1357 1351 return err;