]> Zhao Yanbai Git Server - minix.git/commitdiff
Corrected invalid URBs handling
authorWojciech Zajac <wzajac@jpembedded.eu>
Tue, 24 Jun 2014 09:35:44 +0000 (11:35 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:05:55 +0000 (17:05 +0200)
drivers/usbd/hcd/hcd.c

index 20339c63ee53163d9a821a81e672432b0d6f05be..56687c5b759cf9b3c518821de0cc42c698fbe060 100755 (executable)
@@ -469,35 +469,45 @@ hcd_handle_urb(hcd_device_state * this_device, hcd_urb * urb)
 
        DEBUG_DUMP;
 
-       transfer_status = EXIT_FAILURE;
-
        /* TODO: One device only */
        USB_ASSERT(NULL != urb, "NULL URB given");
        USB_ASSERT(this_device == urb->target_device, "Unknown device for URB");
 
-       switch (urb->type) {
-               case HCD_TRANSFER_CONTROL:
-                       transfer_status = hcd_control_urb(this_device, urb);
-                       break;
-
-               case HCD_TRANSFER_BULK:
-               case HCD_TRANSFER_INTERRUPT:
-                       transfer_status = hcd_non_control_urb(this_device, urb);
-                       break;
-
-               case HCD_TRANSFER_ISOCHRONOUS:
-                       /* TODO: ISO transfer */
-                       USB_MSG("ISO transfer not supported");
-                       break;
+       /* Only if URB parsing was completed... */
+       if (EXIT_SUCCESS == urb->inout_status) {
+
+               transfer_status = EXIT_FAILURE;
+
+               /* ...check for URB to handle */
+               switch (urb->type) {
+                       case HCD_TRANSFER_CONTROL:
+                               transfer_status = hcd_control_urb(
+                                                       this_device, urb);
+                               break;
+
+                       case HCD_TRANSFER_BULK:
+                       case HCD_TRANSFER_INTERRUPT:
+                               transfer_status = hcd_non_control_urb(
+                                                       this_device, urb);
+                               break;
+
+                       case HCD_TRANSFER_ISOCHRONOUS:
+                               /* TODO: ISO transfer */
+                               USB_MSG("ISO transfer not supported");
+                               break;
+
+                       default:
+                               USB_MSG("Invalid transfer type 0x%02X",
+                                                       (int)urb->type);
+                               break;
+               }
 
-               default:
-                       USB_MSG("Invalid transfer type 0x%02X", (int)urb->type);
-                       break;
-       }
+               /* In case of error, only dump message */
+               if (EXIT_SUCCESS != transfer_status)
+                       USB_MSG("USB transfer failed");
 
-       /* In case of error, only dump message */
-       if (EXIT_SUCCESS != transfer_status)
-               USB_MSG("USB transfer failed");
+       } else
+               USB_MSG("Invalid URB supplied");
 
        /* Call completion regardless of status */
        hcd_completion_cb(urb);