From f584c0ca5f5b2035d241cc5ef9c5ebf4fa4de9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 15 Nov 2013 20:06:06 +0100 Subject: [PATCH] XHCI USB: some fixes. * AllocateDevice(): don't include the root port in the route. * SubmitNormalRequest(): fail if we couldn't allocate the a descriptor. --- src/add-ons/kernel/busses/usb/xhci.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index a83075f9d3..660a2a4574 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -597,6 +597,8 @@ XHCI::SubmitNormalRequest(Transfer *transfer) bool directionIn = (pipe->Direction() == Pipe::In); xhci_td *descriptor = CreateDescriptorChain(transfer->DataLength()); + if (descriptor == NULL) + return B_NO_MEMORY; descriptor->trb_count = descriptor->buffer_count; // set NormalStage @@ -1004,12 +1006,16 @@ XHCI::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort, uint8 rhPort = 0; for (Device *hubDevice = parent; hubDevice != RootObject(); hubDevice = (Device *)hubDevice->Parent()) { + + rhPort = routePort; + if (hubDevice->Parent() == RootObject()) + break; route *= 16; if (hubPort > 15) route += 15; else route += routePort; - rhPort = routePort; + routePort = hubDevice->HubPort(); }