diff mbox

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

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

Commit Message

Michael S. Tsirkin March 15, 2016, 3:01 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(