From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6TGQ-0004xr-Vu for qemu-devel@nongnu.org; Mon, 14 Nov 2016 21:14:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6TGN-0006lr-11 for qemu-devel@nongnu.org; Mon, 14 Nov 2016 21:14:22 -0500 Received: from mail-it0-x242.google.com ([2607:f8b0:4001:c0b::242]:33847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6TGM-0006l7-SW for qemu-devel@nongnu.org; Mon, 14 Nov 2016 21:14:18 -0500 Received: by mail-it0-x242.google.com with SMTP id q124so18735831itd.1 for ; Mon, 14 Nov 2016 18:14:18 -0800 (PST) From: Li Qiang Date: Mon, 14 Nov 2016 21:13:53 -0500 Message-Id: <1479176033-36604-4-git-send-email-liq3ea@gmail.com> In-Reply-To: <1479176033-36604-1-git-send-email-liq3ea@gmail.com> References: <1479176033-36604-1-git-send-email-liq3ea@gmail.com> Subject: [Qemu-devel] [PATCH v2 3/3] 9pfs: add cleanup operation for proxy backend driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: groug@kaod.org, qemu-devel@nongnu.org Cc: liqiang6-s@360.cn, 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 --- hw/9pfs/9p-proxy.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index f2417b7..4b22f57 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -1168,9 +1168,19 @@ static int proxy_init(FsContext *ctx) return 0; } +static void proxy_cleanup(FsContext *ctx) +{ + V9fsProxy *proxy = ctx->private; + close(proxy->sockfd); + g_free(proxy->in_iovec.iov_base); + g_free(proxy->out_iovec.iov_base); + 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, -- 1.8.3.1