ChangeSet 1.1595.7.27, 2003/07/31 22:47:24-07:00, stern@rowland.harvard.edu [PATCH] USB: Small fixes for usbtest It fixes a few minor problems in the usbtest driver: Unlinks are done in the expected order, preventing some inappropriate error messages. The driver would wait for an URB to complete, even if the URB got an error on submission. There was a surprising memory leak: the driver didn't kfree() its private data structure. drivers/usb/misc/usbtest.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff -Nru a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c --- a/drivers/usb/misc/usbtest.c Fri Aug 1 10:54:16 2003 +++ b/drivers/usb/misc/usbtest.c Fri Aug 1 10:54:16 2003 @@ -695,8 +695,9 @@ */ /* unlink whatever's still pending */ - for (i = 0; i < ctx->param->sglen; i++) { - struct urb *u = ctx->urb [i]; + for (i = 1; i < ctx->param->sglen; i++) { + struct urb *u = ctx->urb [ + (i + subcase->number) % ctx->param->sglen]; if (u == urb || !u->dev) continue; @@ -893,7 +894,8 @@ /* FIXME set timer and time out; provide a disconnect hook */ /* wait for the last one to complete */ - wait_for_completion (&context.complete); + if (context.pending > 0) + wait_for_completion (&context.complete); cleanup: for (i = 0; i < param->sglen; i++) { @@ -1374,6 +1376,7 @@ usb_set_intfdata (intf, NULL); info ("unbound %s", dev->id); + kfree (dev); } /* Basic testing only needs a device that can source or sink bulk traffic.