[5/5] usb-redir: Don't try to write to the chardev after a close event

Submitted by Hans de Goede on Aug. 11, 2011, 12:25 p.m.

Details

Message ID 1313065515-3815-5-git-send-email-hdegoede@redhat.com
State New
Headers show

Commit Message

Hans de Goede Aug. 11, 2011, 12:25 p.m.
Sicne we handle close async in a bh, do_write and thus write can get
called after receiving a close event. This patch adds a check to
the usb-redir write callback to not do a qemu_chr_write on a closed
chardev.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 usb-redir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/usb-redir.c b/usb-redir.c
index 6d8f986..732ddab 100644
--- a/usb-redir.c
+++ b/usb-redir.c
@@ -226,7 +226,7 @@  static int usbredir_write(void *priv, uint8_t *data, int count)
     USBRedirDevice *dev = priv;
     int r;
 
-    if (dev->cs->write_blocked) {
+    if (!dev->cs->opened || dev->cs->write_blocked) {
         return 0;
     }