From 8d4de8b771b0c0f6f18346471ff6cb3c637b548d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 14 Jul 2016 20:58:02 +0200 Subject: [PATCH 20/27] net: do not use atexit for cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Marc-André Lureau Message-id: <20160714205802.2896-5-marcandre.lureau@redhat.com> Patchwork-id: 71192 O-Subject: [RHEV-7.3 qemu-kvm-rhev PATCH 4/4] net: do not use atexit for cleanup Bugzilla: 1354090 RH-Acked-by: Xiao Wang RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Paolo Bonzini RH-Acked-by: Laurent Vivier From: Paolo Bonzini This will be necessary in the next patch, which stops using atexit for character devices; without it, vhost-user and the redirector filter will cause a use-after-free. Relying on the ordering of atexit calls is also brittle, even now that both the network and chardev subsystems are using atexit. Signed-off-by: Paolo Bonzini (cherry picked from commit 8caf911d3316b6eccc503cff0d9a68cf922950f1) vl.c onflicts due to commit ordering, and default_net handling change. Signed-off-by: Marc-André Lureau Signed-off-by: Miroslav Rezanina --- vl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 2b4e22e..bd013b9 100644 --- a/vl.c +++ b/vl.c @@ -4411,9 +4411,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 (net_init_clients() < 0) { exit(1); } @@ -4673,6 +4670,8 @@ int main(int argc, char **argv, char **envp) #ifdef CONFIG_TPM tpm_cleanup(); #endif + net_cleanup(); + qemu_chr_cleanup(); return 0; -- 1.8.3.1