OSDN Git Service

vhost-user: disable chardev handlers on close
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 29 Jun 2016 13:15:33 +0000 (15:15 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 29 Jun 2016 14:49:40 +0000 (16:49 +0200)
This otherwise causes a use-after-free if network backend cleanup
is performed before character device cleanup.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
net/vhost-user.c

index 636899a..92f4cfd 100644 (file)
@@ -151,6 +151,11 @@ static void vhost_user_cleanup(NetClientState *nc)
         vhost_net_cleanup(s->vhost_net);
         s->vhost_net = NULL;
     }
+    if (s->chr) {
+        qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, NULL);
+        qemu_chr_fe_release(s->chr);
+        s->chr = NULL;
+    }
 
     qemu_purge_queued_packets(nc);
 }