From patchwork Tue Jun 12 02:24:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: linzhecheng X-Patchwork-Id: 928041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 414Ydb6Knyz9s0w for ; Tue, 12 Jun 2018 12:25:39 +1000 (AEST) Received: from localhost ([::1]:52377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSZ05-0007wd-Ga for incoming@patchwork.ozlabs.org; Mon, 11 Jun 2018 22:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSYzm-0007wO-0U for qemu-devel@nongnu.org; Mon, 11 Jun 2018 22:25:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSYzi-0007VW-Qt for qemu-devel@nongnu.org; Mon, 11 Jun 2018 22:25:18 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2550 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSYzi-0007Sa-CP for qemu-devel@nongnu.org; Mon, 11 Jun 2018 22:25:14 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0BBF29B9EABB9; Tue, 12 Jun 2018 10:24:59 +0800 (CST) Received: from localhost (10.177.131.80) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.382.0; Tue, 12 Jun 2018 10:24:49 +0800 From: linzhecheng To: Date: Tue, 12 Jun 2018 10:24:45 +0800 Message-ID: <20180612022445.5192-1-linzhecheng@huawei.com> X-Mailer: git-send-email 2.12.2.windows.2 MIME-Version: 1.0 X-Originating-IP: [10.177.131.80] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH v2] vhost-user: delete net client if necessary 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: linzhecheng , jasowang@redhat.com, wangxinxin.wang@huawei.com, liujunjie23@huawei.com, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: linzhecheng diff --git a/net/vhost-user.c b/net/vhost-user.c index 608b837175..a39f9c9974 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -345,6 +345,9 @@ err: s->vhost_user = NULL; } } + if (nc0) { + qemu_del_net_client(nc0); + } return -1; }