un-register kbd driver in case of USB kbd unplug.

If a USB keyboard is unplugged, the keyboard eventhandler is never
removed, and events will continue to be passed through to the device,
causing crashes or memory corruption.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Jes Sorensen 2010-06-08 15:12:18 +02:00 committed by Anthony Liguori
parent 55541c8afc
commit 46aaebff40
3 changed files with 13 additions and 2 deletions

View file

@ -855,9 +855,13 @@ static void usb_hid_handle_destroy(USBDevice *dev)
{
USBHIDState *s = (USBHIDState *)dev;
if (s->kind != USB_KEYBOARD)
switch(s->kind) {
case USB_KEYBOARD:
qemu_remove_kbd_event_handler();
break;
default:
qemu_remove_mouse_event_handler(s->ptr.eh_entry);
/* TODO: else */
}
}
static int usb_hid_initfn(USBDevice *dev, int kind)