summaryrefslogtreecommitdiffstats
path: root/hw/usb-hid.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2010-06-08 15:12:18 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2010-06-14 15:46:28 -0500
commit46aaebff40f942e7b17b426916a3dee9b8b6f274 (patch)
tree79b45680ef013caa9b558465eaaf666e2dce02c0 /hw/usb-hid.c
parent55541c8afc1a2d75de890c6ee858769d7d605526 (diff)
downloadhqemu-46aaebff40f942e7b17b426916a3dee9b8b6f274.zip
hqemu-46aaebff40f942e7b17b426916a3dee9b8b6f274.tar.gz
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>
Diffstat (limited to 'hw/usb-hid.c')
-rw-r--r--hw/usb-hid.c8
1 files changed, 6 insertions, 2 deletions
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)
OpenPOWER on IntegriCloud