From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gv-0000NL-6P for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gr-0007mN-Rt for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:17 -0400 Sender: fluxion From: Michael Roth Date: Mon, 18 Jun 2018 20:43:16 -0500 Message-Id: <20180619014319.28272-111-mdroth@linux.vnet.ibm.com> In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 110/113] vhost-user: delete net client if necessary List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, linzhecheng , Jason Wang From: linzhecheng As qemu_new_net_client create new ncs but error happens later, ncs will be left in global net_clients list and we can't use them any more, so we need to cleanup them. Cc: qemu-stable@nongnu.org Signed-off-by: linzhecheng Signed-off-by: Jason Wang (cherry picked from commit c67daf4a24442d1bb404a11a6a54dc45ea10f234) Conflicts: net/vhost-user.c * drop functional dep on 4d0cf552 Signed-off-by: Michael Roth --- net/vhost-user.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/vhost-user.c b/net/vhost-user.c index c23927c912..d2015e30b6 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -296,7 +296,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, s = DO_UPCAST(VhostUserState, nc, nc); if (!qemu_chr_fe_init(&s->chr, chr, &err)) { error_report_err(err); - return -1; + goto err; } } @@ -306,7 +306,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, do { if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) { error_report_err(err); - return -1; + goto err; } qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event, NULL, nc0->name, NULL, @@ -316,6 +316,13 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, assert(s->vhost_net); return 0; + +err: + if (nc0) { + qemu_del_net_client(nc0); + } + + return -1; } static Chardev *net_vhost_claim_chardev( -- 2.11.0