XHCI: Delete the device in FreeDevice() before tearing down internal state.

We don't properly tear down endpoints, etc. yet, but when we do, this will
be important as the device destructors are what tells us to do that.
This commit is contained in:
Augustin Cavalier
2019-02-22 17:09:09 -05:00
parent 1464b156f7
commit c4db8aba7b
+5 -1
View File
@@ -1425,6 +1425,11 @@ XHCI::FreeDevice(Device *device)
{
uint8 slot = fPortSlots[device->HubPort()];
TRACE("FreeDevice() port %d slot %d\n", device->HubPort(), slot);
// Delete the device first, so it cleans up its pipes and tells us
// what we need to destroy before we tear down our internal state.
delete device;
DisableSlot(slot);
fDcba->baseAddress[slot] = 0;
fPortSlots[device->HubPort()] = 0;
@@ -1432,7 +1437,6 @@ XHCI::FreeDevice(Device *device)
delete_area(fDevices[slot].input_ctx_area);
delete_area(fDevices[slot].device_ctx_area);
fDevices[slot].state = XHCI_STATE_DISABLED;
delete device;
}