From patchwork Mon Nov 14 12:32:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9427443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7BCFD6047D for ; Mon, 14 Nov 2016 12:42:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78217288C2 for ; Mon, 14 Nov 2016 12:42:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A63628926; Mon, 14 Nov 2016 12:42:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08033288C2 for ; Mon, 14 Nov 2016 12:42:51 +0000 (UTC) Received: from localhost ([::1]:39564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6Gb4-0005d5-Vp for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Nov 2016 07:42:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6GT1-0007IY-27 for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6GSx-0003jB-Uu for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:31 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6GSx-0003iS-PN for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:27 -0500 Received: by mail-pf0-f193.google.com with SMTP id i88so6151224pfk.2 for ; Mon, 14 Nov 2016 04:34:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date:in-reply-to:references; bh=ZTrLXyrg+OxVEe2nzQWxjRJ6cqpfUupig+YjYJHTilQ=; b=LothKzJUhk+XbDpAmISIPbEJ9OfrasMquPQHQH6rgZMq5NBmbzP+JLJgWjkVdY81/U SjDFBXkk+/+C2sJK7Sp3uSheciaKPZy+zGZb8YWc66VCvMc/gmzlnko9yVVo5MNynG8h 5D6SfOxkMiOtqogr6q+wCsG9ow0FAyWOTxu4u8n1M3ygcTAhJGpzief3t2hmzt60u3we 2OFYH1knn+/h0zkHgTyv4Qeih8szN71e2+eOgG3uJ+uz52U0p8v5ZntSWOtysp3qz206 pgEwIv5GL9fDd6q5IX8rQuFRvyafIZU+YvLTdIPGwfr1QV/XTz5oklZ8O95Cklf8fyFq 8vHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references; bh=ZTrLXyrg+OxVEe2nzQWxjRJ6cqpfUupig+YjYJHTilQ=; b=i17Cfruc0hx8F8LksvwGT7xxng8dzvdjWZkc3ZlWDBpuFhFRijj/U91zjt6eq851iX bpZNzDou09hm1mtVeglp8Blp2yZtAr7Nx0TT+jWGxaQXb+8iKU+2X6DfstEg7nKCM21q sXAiJ+X6mqOlEDVDxATHg+NhWkiziunuaagrYWL5betSruytOjYb66SX/FhVqk/oePP9 8o8wn0wRcfFmtuMnPKwyU/2DzBaV4DSCciKluj0QufogHeNtoYuCMzK/fFUr79ENX3PD vRiNix9ZgkN/rej9Q+dyCgjFoeQeXZQ4yBw5XkzKq9XZLZEQUA81x3HNUaQ+m8/ZVmO2 y8bA== X-Gm-Message-State: ABUngvcVEn0dIDRGhsP1wJrIyv8q2i+KNfCXrnUr1QmPWUVf/cko9D7q/P2e2Zvs5XMvjw== X-Received: by 10.98.81.70 with SMTP id f67mr35202775pfb.179.1479126806994; Mon, 14 Nov 2016 04:33:26 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id xg4sm35177845pac.39.2016.11.14.04.33.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 04:33:26 -0800 (PST) Message-ID: <5829af16.84f4420a.a436f.4a79@mx.google.com> X-Google-Original-Message-ID: <1479126778-125867-4-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: groug@kaod.org, qemu-devel@nongnu.org Date: Mon, 14 Nov 2016 07:32:58 -0500 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1479126778-125867-1-git-send-email-Qiang(liqiang6-s@360.cn)> References: <1479126778-125867-1-git-send-email-Qiang(liqiang6-s@360.cn)> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.193 Subject: [Qemu-devel] [PATCH 3/3] 9pfs: add cleanup operation for proxy backend driver 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: Li Qiang , liqiang6-s@360.cn Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,