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:
@@ -170,13 +170,6 @@ usb_hid_device_removed(void *cookie)
|
|||||||
if (device->ParentCookie() != parentCookie)
|
if (device->ParentCookie() != parentCookie)
|
||||||
continue;
|
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
|
// remove all the handlers
|
||||||
for (uint32 i = 0;; i++) {
|
for (uint32 i = 0;; i++) {
|
||||||
handler = device->ProtocolHandlerAt(i);
|
handler = device->ProtocolHandlerAt(i);
|
||||||
@@ -186,7 +179,13 @@ usb_hid_device_removed(void *cookie)
|
|||||||
gDeviceList->RemoveDevice(NULL, handler);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,14 +286,6 @@ usb_hid_free(void *_cookie)
|
|||||||
} else if (device->IsRemoved()) {
|
} else if (device->IsRemoved()) {
|
||||||
// the parent device is removed already and none of its handlers are
|
// the parent device is removed already and none of its handlers are
|
||||||
// open anymore so we can free it here
|
// 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;
|
delete device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user