From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9auP-0006fy-2H for qemu-devel@nongnu.org; Wed, 23 Nov 2016 12:00:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9auL-0007C1-Us for qemu-devel@nongnu.org; Wed, 23 Nov 2016 12:00:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38011 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9auL-0007B2-NW for qemu-devel@nongnu.org; Wed, 23 Nov 2016 12:00:29 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uANH0NbV075118 for ; Wed, 23 Nov 2016 12:00:29 -0500 Received: from e06smtp08.uk.ibm.com (e06smtp08.uk.ibm.com [195.75.94.104]) by mx0a-001b2d01.pphosted.com with ESMTP id 26wdx7vugn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 23 Nov 2016 12:00:26 -0500 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 Nov 2016 16:59:03 -0000 From: Greg Kurz Date: Wed, 23 Nov 2016 17:58:18 +0100 In-Reply-To: <1479920298-24983-1-git-send-email-groug@kaod.org> References: <1479920298-24983-1-git-send-email-groug@kaod.org> Message-Id: <1479920298-24983-5-git-send-email-groug@kaod.org> Subject: [Qemu-devel] [for-2.8 4/4] 9pfs: add cleanup operation for proxy backend driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Aneesh Kumar K.V" , Greg Kurz , Li Qiang From: Li Qiang In the init operation of proxy backend dirver, it allocates a V9fsProxy struct and some other resources. We should free these resources when the 9pfs device is unrealized. This is what this patch does. Signed-off-by: Li Qiang Reviewed-by: Greg Kurz Signed-off-by: Greg Kurz --- hw/9pfs/9p-proxy.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index f2417b7fd73d..f4aa7a9d70f8 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -1168,9 +1168,22 @@ static int proxy_init(FsContext *ctx) return 0; } +static void proxy_cleanup(FsContext *ctx) +{ + V9fsProxy *proxy = ctx->private; + + g_free(proxy->out_iovec.iov_base); + g_free(proxy->in_iovec.iov_base); + if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { + close(proxy->sockfd); + } + g_free(proxy); +} + FileOperations proxy_ops = { .parse_opts = proxy_parse_opts, .init = proxy_init, + .cleanup = proxy_cleanup, .lstat = proxy_lstat, .readlink = proxy_readlink, .close = proxy_close, -- 2.7.4