]>
Commit | Line | Data |
---|---|---|
f262231e WB |
1 | From ae9b5c9dae96dd8d3bdf9bb6b9a0f7a2d6f532f7 Mon Sep 17 00:00:00 2001 |
2 | From: Li Qiang <liq3ea@gmail.com> | |
3 | Date: Wed, 23 Nov 2016 13:53:34 +0100 | |
4 | Subject: [PATCH 09/12] 9pfs: add cleanup operation for proxy backend driver | |
5 | ||
6 | In the init operation of proxy backend dirver, it allocates a | |
7 | V9fsProxy struct and some other resources. We should free these | |
8 | resources when the 9pfs device is unrealized. This is what this | |
9 | patch does. | |
10 | ||
11 | Signed-off-by: Li Qiang <liq3ea@gmail.com> | |
12 | Reviewed-by: Greg Kurz <groug@kaod.org> | |
13 | Signed-off-by: Greg Kurz <groug@kaod.org> | |
14 | --- | |
15 | hw/9pfs/9p-proxy.c | 13 +++++++++++++ | |
16 | 1 file changed, 13 insertions(+) | |
17 | ||
18 | diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c | |
19 | index f265501..336e9fe 100644 | |
20 | --- a/hw/9pfs/9p-proxy.c | |
21 | +++ b/hw/9pfs/9p-proxy.c | |
22 | @@ -1179,9 +1179,22 @@ static int proxy_init(FsContext *ctx) | |
23 | return 0; | |
24 | } | |
25 | ||
26 | +static void proxy_cleanup(FsContext *ctx) | |
27 | +{ | |
28 | + V9fsProxy *proxy = ctx->private; | |
29 | + | |
30 | + g_free(proxy->out_iovec.iov_base); | |
31 | + g_free(proxy->in_iovec.iov_base); | |
32 | + if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { | |
33 | + close(proxy->sockfd); | |
34 | + } | |
35 | + g_free(proxy); | |
36 | +} | |
37 | + | |
38 | FileOperations proxy_ops = { | |
39 | .parse_opts = proxy_parse_opts, | |
40 | .init = proxy_init, | |
41 | + .cleanup = proxy_cleanup, | |
42 | .lstat = proxy_lstat, | |
43 | .readlink = proxy_readlink, | |
44 | .close = proxy_close, | |
45 | -- | |
46 | 2.1.4 | |
47 |