Corrected invalid URBs handling

This commit is contained in:
Wojciech Zajac 2014-06-24 11:35:44 +02:00 committed by Lionel Sambuc
parent e858b9b5e9
commit 6763c425bb

View file

@ -469,20 +469,26 @@ hcd_handle_urb(hcd_device_state * this_device, hcd_urb * urb)
DEBUG_DUMP; DEBUG_DUMP;
transfer_status = EXIT_FAILURE;
/* TODO: One device only */ /* TODO: One device only */
USB_ASSERT(NULL != urb, "NULL URB given"); USB_ASSERT(NULL != urb, "NULL URB given");
USB_ASSERT(this_device == urb->target_device, "Unknown device for URB"); USB_ASSERT(this_device == urb->target_device, "Unknown device for URB");
/* Only if URB parsing was completed... */
if (EXIT_SUCCESS == urb->inout_status) {
transfer_status = EXIT_FAILURE;
/* ...check for URB to handle */
switch (urb->type) { switch (urb->type) {
case HCD_TRANSFER_CONTROL: case HCD_TRANSFER_CONTROL:
transfer_status = hcd_control_urb(this_device, urb); transfer_status = hcd_control_urb(
this_device, urb);
break; break;
case HCD_TRANSFER_BULK: case HCD_TRANSFER_BULK:
case HCD_TRANSFER_INTERRUPT: case HCD_TRANSFER_INTERRUPT:
transfer_status = hcd_non_control_urb(this_device, urb); transfer_status = hcd_non_control_urb(
this_device, urb);
break; break;
case HCD_TRANSFER_ISOCHRONOUS: case HCD_TRANSFER_ISOCHRONOUS:
@ -491,7 +497,8 @@ hcd_handle_urb(hcd_device_state * this_device, hcd_urb * urb)
break; break;
default: default:
USB_MSG("Invalid transfer type 0x%02X", (int)urb->type); USB_MSG("Invalid transfer type 0x%02X",
(int)urb->type);
break; break;
} }
@ -499,6 +506,9 @@ hcd_handle_urb(hcd_device_state * this_device, hcd_urb * urb)
if (EXIT_SUCCESS != transfer_status) if (EXIT_SUCCESS != transfer_status)
USB_MSG("USB transfer failed"); USB_MSG("USB transfer failed");
} else
USB_MSG("Invalid URB supplied");
/* Call completion regardless of status */ /* Call completion regardless of status */
hcd_completion_cb(urb); hcd_completion_cb(urb);