From patchwork Fri Jul 8 15:27:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9221217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14AFB60467 for ; Fri, 8 Jul 2016 15:28:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 079D8288AA for ; Fri, 8 Jul 2016 15:28:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0B19288AC; Fri, 8 Jul 2016 15:28:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E5877288AA for ; Fri, 8 Jul 2016 15:28:24 +0000 (UTC) Received: from localhost ([::1]:46269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLXhX-00081d-GZ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Jul 2016 11:28:23 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=BnPTqQGm+u852/+1vrCCrRlCGtzEZiFX7H9siouDp0E=; b=NUJknBqlDBluZNcZnqKAgiY4JVpmE7ZoGGvmcQIDxYp5opIcM4PbemnUkQVWK1d9nC 2X0qpjMA/UkVuTdvVvs+fP//P9iuNSPR8mlMK94IudcMfXUt4/NX3CpT5/IqJKSLMec2 s2CCSpNFzsZ9V3Tn/fCpjRgkpDzkIzG5JvQAgIz53p+kvZ+jWpAy9B0M1GI7/NiEL/of acysno8WszLDa70Vl9BiLO7mMnF/yF0+HtLDOym25KfEnhoV9hdzUxS8iFY+k9YomQ6+ ylMg7GmJpiwCDV52Ok0hAGWoEHAKebMFvykehE+0+PiI7VXPOm+jNID2l7LXm92X0ut0 xTQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=BnPTqQGm+u852/+1vrCCrRlCGtzEZiFX7H9siouDp0E=; b=EZPeUrtEZT9Y8WWVb5qobmbzG1wWjyUkhM7aeib2ipeuruOqwKmgbbrHwCyzBn1Pa8 rJWdNLDGb14IfKtHme1+Qnorqt2PLvQ69O/WRw5aNMMtlyQUUuIwTsTC0FnxbGHJimFJ 1Ln4+tCobe5F2+yyyaM141mW4CWlDeM6gCTfLmXhEKzSp78R1LmSJGorbIRddE1Kb2bq 2WZ9TnSxmDp/BFv7LrXuEVqkH49JvoTxHfba1T4ATOQF9L5YVHK2uMYowfeqE9Fsy/TS 3KSusZbQj1/1CALdvIvJhO6R2siiozzjPipbfRJBkcA0pyM8KBX7EIsN9w2XMljpJ44Q eYNw== X-Gm-Message-State: ALyK8tLUyMcQXkJjs4Cqr+zGk9uYdXlhaA4lL66ix3ZVDBYF0IBAwstA9410g1Omark16Q== X-Received: by 10.194.87.169 with SMTP id az9mr5939305wjb.158.1467991674496; Fri, 08 Jul 2016 08:27:54 -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 k6sm2315478wjz.28.2016.07.08.08.27.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jul 2016 08:27:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 8 Jul 2016 17:27:51 +0200 Message-Id: <1467991671-93391-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH] net: cleanup before character devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Jason Wang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Otherwise, vhost-user causes a use-after-free. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-André Lureau --- 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;