Patchwork [2/2] usb-redir: fix use-after-free

login
register
mail settings
Submitter Gerd Hoffmann
Date Aug. 1, 2013, 1:11 p.m.
Message ID <1375362669-14815-3-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/264175/
State New
Headers show

Comments

Gerd Hoffmann - Aug. 1, 2013, 1:11 p.m.
Reinitialize dev->cs to NULL after deleting it, to make sure it isn't
used afterwards.

Reported-by: Martin Cerveny <M.Cerveny@computer.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/redirect.c |    1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 8b8c010..e3b9f32 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1334,6 +1334,7 @@  static void usbredir_handle_destroy(USBDevice *udev)
     USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);
 
     qemu_chr_delete(dev->cs);
+    dev->cs = NULL;
     /* Note must be done after qemu_chr_close, as that causes a close event */
     qemu_bh_delete(dev->chardev_close_bh);