From 25f0d2aa5e3d21caa1bc622b21368cc2e383f02c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 29 Jun 2016 15:15:33 +0200 Subject: [PATCH] vhost-user: disable chardev handlers on close MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This otherwise causes a use-after-free if network backend cleanup is performed before character device cleanup. Cc: Marc-André Lureau Signed-off-by: Paolo Bonzini --- net/vhost-user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/vhost-user.c b/net/vhost-user.c index 636899a877..92f4cfd1b1 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -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); } -- 2.11.4.GIT