From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6awZ-0004Jw-Ie for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:26:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6awU-0000ii-MP for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:26:23 -0500 Received: from 4.mo53.mail-out.ovh.net ([188.165.36.167]:60845) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6awU-0000iT-G6 for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:26:18 -0500 Received: from player158.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo53.mail-out.ovh.net (Postfix) with ESMTP id 51B7643634 for ; Tue, 15 Nov 2016 11:26:17 +0100 (CET) Date: Tue, 15 Nov 2016 11:26:14 +0100 From: Greg Kurz Message-ID: <20161115112614.2cec1262@bahia> In-Reply-To: <1479176033-36604-4-git-send-email-liq3ea@gmail.com> References: <1479176033-36604-1-git-send-email-liq3ea@gmail.com> <1479176033-36604-4-git-send-email-liq3ea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [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: Li Qiang Cc: qemu-devel@nongnu.org, liqiang6-s@360.cn On Mon, 14 Nov 2016 21:13:53 -0500 Li Qiang wrote: > 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 > --- Oops I gave my R-b tag a bit to fast because... > 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); ... this should only be done if QEMU opened the fd (i.e. V9FS_PROXY_SOCK_NAME) > + 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,