diff --git a/src/add-ons/kernel/bus_managers/usb/BusManager.cpp b/src/add-ons/kernel/bus_managers/usb/BusManager.cpp index 99f7953866..f6305802c7 100644 --- a/src/add-ons/kernel/bus_managers/usb/BusManager.cpp +++ b/src/add-ons/kernel/bus_managers/usb/BusManager.cpp @@ -14,7 +14,7 @@ BusManager::BusManager(Stack *stack) : fInitOK(false), fStack(stack), fRootHub(NULL), - fUSBID(fStack->IndexOfBusManager(this)) + fUSBID((uint32)-1) { mutex_init(&fLock, "usb busmanager lock"); @@ -253,6 +253,8 @@ BusManager::FreeDevice(Device *device) status_t BusManager::Start() { + fStack->AddBusManager(this); + fUSBID = fStack->IndexOfBusManager(this); return B_OK; } diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp b/src/add-ons/kernel/busses/usb/ehci.cpp index b45541ea46..9c6bd23a85 100644 --- a/src/add-ons/kernel/busses/usb/ehci.cpp +++ b/src/add-ons/kernel/busses/usb/ehci.cpp @@ -1216,8 +1216,10 @@ EHCI::AddTo(Stack *stack) // the bus took it away item = new(std::nothrow) pci_info; - bus->Start(); - stack->AddBusManager(bus); + if (bus->Start() != B_OK) { + delete bus; + continue; + } found = true; } } diff --git a/src/add-ons/kernel/busses/usb/ohci.cpp b/src/add-ons/kernel/busses/usb/ohci.cpp index 7bf1513b30..ded588e16a 100644 --- a/src/add-ons/kernel/busses/usb/ohci.cpp +++ b/src/add-ons/kernel/busses/usb/ohci.cpp @@ -647,8 +647,10 @@ OHCI::AddTo(Stack *stack) // the bus took it away item = new(std::nothrow) pci_info; - bus->Start(); - stack->AddBusManager(bus); + if (bus->Start() != B_OK) { + delete bus; + continue; + } found = true; } } diff --git a/src/add-ons/kernel/busses/usb/uhci.cpp b/src/add-ons/kernel/busses/usb/uhci.cpp index 8d6f4e361c..ade4ca7114 100644 --- a/src/add-ons/kernel/busses/usb/uhci.cpp +++ b/src/add-ons/kernel/busses/usb/uhci.cpp @@ -1923,8 +1923,10 @@ UHCI::AddTo(Stack *stack) // the bus took it away item = new(std::nothrow) pci_info; - bus->Start(); - stack->AddBusManager(bus); + if (bus->Start() != B_OK) { + delete bus; + continue; + } found = true; } } diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index b6cf4b13fd..07382ccc5f 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -864,8 +864,10 @@ XHCI::AddTo(Stack *stack) // the bus took it away item = new(std::nothrow) pci_info; - bus->Start(); - stack->AddBusManager(bus); + if (bus->Start() != B_OK) { + delete bus; + continue; + } found = true; } }