Received: from eggs.gnu.org ([2001:4830:134:3::10]:52252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKBf-0001zQ-Ud for qemu-devel@nongnu.org; Wed, 13 Jul 2016 09:26:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNKBa-0003Cz-CY for qemu-devel@nongnu.org; Wed, 13 Jul 2016 09:26:51 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKBa-0003CV-63 for qemu-devel@nongnu.org; Wed, 13 Jul 2016 09:26:46 -0400 Received: by mail-wm0-x243.google.com with SMTP id x83so5865123wma.3 for ; Wed, 13 Jul 2016 06:26:46 -0700 (PDT) Received: from 640k.lan (94-39-188-118.adsl-ull.clienti.tiscali.it. [94.39.188.118]) by smtp.gmail.com with ESMTPSA id 207sm32565872wmb.7.2016.07.13.06.26.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jul 2016 06:26:44 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 13 Jul 2016 15:26:29 +0200 Message-Id: <1468416392-120170-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1468416392-120170-1-git-send-email-pbonzini@redhat.com> References: <1468416392-120170-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 11/14] net: do not use atexit for cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- vl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 356713e..cad4da2 100644 --- a/vl.c +++ b/vl.c @@ -4345,9 +4345,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); @@ -4611,5 +4608,7 @@ int main(int argc, char **argv, char **envp) tpm_cleanup(); #endif + net_cleanup(); + return 0; } -- 1.8.3.1