Skip to content

Commit

Permalink
USB: usbtest fix endless loop in unlink tests.
Browse files Browse the repository at this point in the history
In tests 11 and 12 if the URB completes with an error status (eg babble)
the asynchrous unlink entered an endless loop trying to unlink
a non resubmitted URB.

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Martin Fuzzey authored and Greg Kroah-Hartman committed Jun 16, 2009
1 parent e60c65d commit 3b6c023
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions drivers/usb/misc/usbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,23 +1072,34 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
*/
msleep (jiffies % (2 * INTERRUPT_RATE));
if (async) {
retry:
retval = usb_unlink_urb (urb);
if (retval == -EBUSY || retval == -EIDRM) {
/* we can't unlink urbs while they're completing.
* or if they've completed, and we haven't resubmitted.
* "normal" drivers would prevent resubmission, but
* since we're testing unlink paths, we can't.
*/
ERROR(dev, "unlink retry\n");
goto retry;
while (!completion_done(&completion)) {
retval = usb_unlink_urb(urb);

switch (retval) {
case -EBUSY:
case -EIDRM:
/* we can't unlink urbs while they're completing
* or if they've completed, and we haven't
* resubmitted. "normal" drivers would prevent
* resubmission, but since we're testing unlink
* paths, we can't.
*/
ERROR(dev, "unlink retry\n");
continue;
case 0:
case -EINPROGRESS:
break;

default:
dev_err(&dev->intf->dev,
"unlink fail %d\n", retval);
return retval;
}

break;
}
} else
usb_kill_urb (urb);
if (!(retval == 0 || retval == -EINPROGRESS)) {
dev_err(&dev->intf->dev, "unlink fail %d\n", retval);
return retval;
}

wait_for_completion (&completion);
retval = urb->status;
Expand Down

0 comments on commit 3b6c023

Please sign in to comment.