diff mbox

[PULL,30/53] qemu-char: make tcp_chr_disconnect() reentrant-safe

Message ID 1457708548-14093-31-git-send-email-mst@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael S. Tsirkin March 11, 2016, 3:09 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

During CHR_EVENT_CLOSED, the function could be reentered, make this
case safe.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 qemu-char.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 3813efd..27fbb44 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2769,6 +2769,10 @@  static void tcp_chr_disconnect(CharDriverState *chr)
 {
     TCPCharDriver *s = chr->opaque;
 
+    if (!s->connected) {
+        return;
+    }
+
     s->connected = 0;
     if (s->listen_ioc) {
         s->listen_tag = qio_channel_add_watch(