]> git.hungrycats.org Git - linux/commitdiff
[PATCH] USB: usb_hcd_unlink_urb() test for list membership
authorDavid Brownell <david-b@pacbell.net>
Tue, 9 Dec 2003 10:05:06 +0000 (02:05 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 9 Dec 2003 10:05:06 +0000 (02:05 -0800)
This is a minor cleanup that replaces a test for non-null urb->hcpriv
with "is the urb on this list".  HCDs don't need to use hcpriv in that
way, and in general this is a safer way to test that.  (AIO does much
the same thing in its kiocb cancelation paths.)

drivers/usb/core/hcd.c

index 2666066e785ba2b7586f4e486c6c54c4c5f998b7..d4e4afda1e7474c7410f0e29f0ba4502bdcaea28 100644 (file)
@@ -1165,6 +1165,7 @@ static int hcd_unlink_urb (struct urb *urb)
        struct device                   *sys = 0;
        unsigned long                   flags;
        struct completion_splice        splice;
+       struct list_head                *tmp;
        int                             retval;
 
        if (!urb)
@@ -1203,7 +1204,12 @@ static int hcd_unlink_urb (struct urb *urb)
         */
        WARN_ON (!HCD_IS_RUNNING (hcd->state) && hcd->state != USB_STATE_HALT);
 
-       if (!urb->hcpriv) {
+       /* insist the urb is still queued */
+       list_for_each(tmp, &dev->urb_list) {
+               if (tmp == &urb->urb_list)
+                       break;
+       }
+       if (tmp != &urb->urb_list) {
                retval = -EINVAL;
                goto done;
        }