From 7f440923c899626f39cb56c6a923ecf4b61566dd Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Sun, 15 Mar 2015 15:48:16 +0000 Subject: [PATCH] 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 --- .../kernel/drivers/input/usb_hid/Driver.cpp | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp index 51ca81f02a..f194056bf3 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp @@ -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; }