From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLXhB-0007zB-6O for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:28:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLXh6-0007s3-3D for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:28:00 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLXh5-0007rh-SO for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:27:56 -0400 Received: by mail-pf0-x242.google.com with SMTP id t190so8325579pfb.2 for ; Fri, 08 Jul 2016 08:27:55 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 8 Jul 2016 17:27:51 +0200 Message-Id: <1467991671-93391-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] net: cleanup before character devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jason Wang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Otherwise, vhost-user causes a use-after-free. Signed-off-by: Paolo Bonzini --- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index d0b9ff9..005162d 100644 --- a/vl.c +++ b/vl.c @@ -4327,9 +4327,6 @@ int main(int argc, char **argv, char **envp) qemu_opts_del(icount_opts); } - /* clean up network at qemu process termination */ - atexit(&net_cleanup); - if (default_net) { QemuOptsList *net = qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); @@ -4596,6 +4593,9 @@ int main(int argc, char **argv, char **envp) #ifdef CONFIG_TPM tpm_cleanup(); #endif + + /* vhost-user must be cleaned up before chardevs. */ + net_cleanup(); qemu_chr_cleanup(); return 0; -- 1.8.3.1