From patchwork Tue Feb 13 05:08:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: linzhecheng X-Patchwork-Id: 872610 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=) 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 3zgVw94yC4z9sNw for ; Tue, 13 Feb 2018 16:10:00 +1100 (AEDT) Received: from localhost ([::1]:42858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elSqp-00083g-M9 for incoming@patchwork.ozlabs.org; Tue, 13 Feb 2018 00:09:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elSqP-00082u-KY for qemu-devel@nongnu.org; Tue, 13 Feb 2018 00:09:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elSqL-0002z0-KB for qemu-devel@nongnu.org; Tue, 13 Feb 2018 00:09:29 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2167 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1elSqL-0002xq-9a for qemu-devel@nongnu.org; Tue, 13 Feb 2018 00:09:25 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 140BCF07E05E6; Tue, 13 Feb 2018 13:09:10 +0800 (CST) Received: from localhost (10.177.131.80) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Tue, 13 Feb 2018 13:09:05 +0800 From: linzhecheng To: Date: Tue, 13 Feb 2018 13:08:37 +0800 Message-ID: <20180213050837.40964-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.190 Subject: [Qemu-devel] [PATCH v2] vhost-user: fix memory leak 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 , mst@redhat.com, wangxinxin.wang@huawei.com, f4bug@amsat.org, lidonglin@huawei.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" g_free() was moved from vhost_net_cleanup in commit e6bcb1b, so we should free net after vhost_net_cleanup Signed-off-by: linzhecheng Reviewed-by: Marc-André Lureau < marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé diff --git a/net/vhost-user.c b/net/vhost-user.c index cb45512506..d024573e45 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -109,6 +109,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be) err: if (net) { vhost_net_cleanup(net); + g_free(net); } vhost_user_stop(i, ncs); return -1;