usb_hid: make sure removed devices do not get published

On many SMP systems, publish_devices() would get called before the
free() hook was triggered, resulting in removed devices still being
published.

Fix sponsered by http://www.izcorp.com
This commit is contained in:
Ithamar R. Adema 2015-03-15 15:48:16 +00:00
parent 7f0d2c98b6
commit 7f440923c8

View File

@ -170,13 +170,6 @@ usb_hid_device_removed(void *cookie)
if (device->ParentCookie() != parentCookie)
continue;
// this handler's device belongs to the one removed
if (device->IsOpen()) {
// the device and it's handlers will be deleted in the free hook
device->Removed();
break;
}
// remove all the handlers
for (uint32 i = 0;; i++) {
handler = device->ProtocolHandlerAt(i);
@ -186,7 +179,13 @@ usb_hid_device_removed(void *cookie)
gDeviceList->RemoveDevice(NULL, handler);
}
delete device;
// this handler's device belongs to the one removed
if (device->IsOpen()) {
// the device and it's handlers will be deleted in the free hook
device->Removed();
} else
delete device;
break;
}
@ -287,14 +286,6 @@ usb_hid_free(void *_cookie)
} else if (device->IsRemoved()) {
// the parent device is removed already and none of its handlers are
// open anymore so we can free it here
for (uint32 i = 0;; i++) {
ProtocolHandler *handler = device->ProtocolHandlerAt(i);
if (handler == NULL)
break;
gDeviceList->RemoveDevice(NULL, handler);
}
delete device;
}