From: Jes.Sorensen@redhat.com
To: anthony@codemonkey.ws
Cc: shavivi@redhat.com, qemu-devel@nongnu.org,
Jes Sorensen <Jes.Sorensen@redhat.com>
Subject: [Qemu-devel] [PATCH] un-register kbd driver in case of USB kbd unplug.
Date: Tue, 8 Jun 2010 12:43:51 +0200 [thread overview]
Message-ID: <1275993831-31425-2-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1275993831-31425-1-git-send-email-Jes.Sorensen@redhat.com>
From: Jes Sorensen <Jes.Sorensen@redhat.com>
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>
---
console.h | 1 +
hw/usb-hid.c | 3 +++
input.c | 6 ++++++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/console.h b/console.h
index cac959f..aafb031 100644
--- a/console.h
+++ b/console.h
@@ -42,6 +42,7 @@ typedef struct QEMUPutLEDEntry {
} QEMUPutLEDEntry;
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
+void qemu_remove_kbd_event_handler(void);
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
void *opaque, int absolute,
const char *name);
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 8e6c6e0..333b626 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -856,6 +856,9 @@ static void usb_hid_handle_destroy(USBDevice *dev)
if (s->kind != USB_KEYBOARD)
qemu_remove_mouse_event_handler(s->ptr.eh_entry);
+ if (s->kind == USB_KEYBOARD)
+ qemu_remove_kbd_event_handler();
+
/* TODO: else */
}
diff --git a/input.c b/input.c
index 651442d..ec05548 100644
--- a/input.c
+++ b/input.c
@@ -42,6 +42,12 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
qemu_put_kbd_event = func;
}
+void qemu_remove_kbd_event_handler(void)
+{
+ qemu_put_kbd_event_opaque = NULL;
+ qemu_put_kbd_event = NULL;
+}
+
static void check_mode_change(void)
{
static int current_is_absolute, current_has_absolute;
--
1.6.5.2
next prev parent reply other threads:[~2010-06-08 10:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 10:43 [Qemu-devel] [PATCH] un-register kbd driver for USB kbd unplug Jes.Sorensen
2010-06-08 10:43 ` Jes.Sorensen [this message]
2010-06-08 12:14 ` [Qemu-devel] " Shahar Havivi
-- strict thread matches above, loose matches on Subject: below --
2010-06-08 13:12 [Qemu-devel] [PATCH v2] " Jes.Sorensen
2010-06-08 13:12 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
2010-06-09 7:52 ` Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1275993831-31425-2-git-send-email-Jes.Sorensen@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
--cc=shavivi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).