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 a1435c457c..9dbed21dac 100644
a
|
b
|
usb_hid_device_removed(void *cookie)
|
192 | 192 | int32 parentCookie = (int32)(addr_t)cookie; |
193 | 193 | TRACE("device_removed(%" B_PRId32 ")\n", parentCookie); |
194 | 194 | |
| 195 | // removed device may contains multiple hid devices on multiple interfaces |
| 196 | // we must go through all published devices and remove all that belong to this parent |
195 | 197 | for (int32 i = 0; i < gDeviceList->CountDevices(); i++) { |
196 | 198 | ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->DeviceAt(i); |
197 | 199 | if (!handler) |
… |
… |
usb_hid_device_removed(void *cookie)
|
202 | 204 | continue; |
203 | 205 | |
204 | 206 | // remove all the handlers |
205 | | for (uint32 i = 0;; i++) { |
206 | | handler = device->ProtocolHandlerAt(i); |
| 207 | for (uint32 j = 0;; j++) { |
| 208 | handler = device->ProtocolHandlerAt(j); |
207 | 209 | if (handler == NULL) |
208 | 210 | break; |
209 | 211 | |
210 | 212 | gDeviceList->RemoveDevice(NULL, handler); |
| 213 | i--; // device count changed, adjust index |
211 | 214 | } |
212 | 215 | |
213 | 216 | // this handler's device belongs to the one removed |
… |
… |
usb_hid_device_removed(void *cookie)
|
216 | 219 | device->Removed(); |
217 | 220 | } else |
218 | 221 | delete device; |
219 | | |
220 | | break; |
221 | 222 | } |
222 | 223 | |
223 | 224 | mutex_unlock(&sDriverLock); |