From: Anthony Liguori <anthony@codemonkey.ws>
To: Jes.Sorensen@redhat.com
Cc: kwolf@redhat.com, shavivi@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] un-register kbd driver in case of USB kbd unplug.
Date: Mon, 14 Jun 2010 15:57:33 -0500 [thread overview]
Message-ID: <4C1697BD.70706@codemonkey.ws> (raw)
In-Reply-To: <1276002738-821-2-git-send-email-Jes.Sorensen@redhat.com>
On 06/08/2010 08:12 AM, Jes.Sorensen@redhat.com wrote:
> 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>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> console.h | 1 +
> hw/usb-hid.c | 8 ++++++--
> input.c | 6 ++++++
> 3 files changed, 13 insertions(+), 2 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..ca04511 100644
> --- a/hw/usb-hid.c
> +++ b/hw/usb-hid.c
> @@ -854,9 +854,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)
> 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;
>
next prev parent reply other threads:[~2010-06-14 20:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 13:12 [Qemu-devel] [PATCH v2] un-register kbd driver for USB kbd unplug 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-06-08 10:43 [Qemu-devel] [PATCH] un-register kbd driver for " Jes.Sorensen
2010-06-08 10:43 ` [Qemu-devel] [PATCH] un-register kbd driver in case of " Jes.Sorensen
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=4C1697BD.70706@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=Jes.Sorensen@redhat.com \
--cc=kwolf@redhat.com \
--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).