The xHCI slot ID is one-based, not zero-based. Fix the length of the
xhci->slot[] array to account for this, and add assertions to check
that the hardware returns a valid slot ID in response to the Enable
Slot command.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
rc = id;
goto err_enable_slot;
}
+ assert ( ( id > 0 ) && ( id <= xhci->slots ) );
assert ( xhci->slot[id] == NULL );
/* Allocate and initialise structure */
int rc;
/* Allocate device slot array */
- xhci->slot = zalloc ( xhci->slots * sizeof ( xhci->slot[0] ) );
+ xhci->slot = zalloc ( ( xhci->slots + 1 ) * sizeof ( xhci->slot[0] ) );
if ( ! xhci->slot ) {
rc = -ENOMEM;
goto err_slot_alloc;
/* Sanity checks */
assert ( xhci->slot != NULL );
- for ( i = 0 ; i < xhci->slots ; i++ )
+ for ( i = 0 ; i <= xhci->slots ; i++ )
assert ( xhci->slot[i] == NULL );
xhci_stop ( xhci );