From 46aaebff40f942e7b17b426916a3dee9b8b6f274 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 8 Jun 2010 15:12:18 +0200 Subject: 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 Signed-off-by: Anthony Liguori --- hw/usb-hid.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'hw/usb-hid.c') diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 228d0a0..882d933 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -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) -- cgit v1.1