From 9f7bd36edf3f0a9c634db019d28335f4320ad41e Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 10 Oct 2017 13:51:46 +0200 Subject: gfapi: free xlator_cmdline_option_t when set through glfs_set_xlator_option() Change-Id: I10c323477534fd50d29460cf71c246378659fca5 BUG: 1443145 Signed-off-by: Niels de Vos --- api/src/glfs.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'api/src') diff --git a/api/src/glfs.c b/api/src/glfs.c index db3ea10bb84..72a2c3724a1 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -522,7 +522,7 @@ GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_set_volfile_server, 3.4.0); /* * * Used to free the arguments allocated by glfs_set_volfile_server() */ -void +static void glfs_free_volfile_servers (cmd_args_t *cmd_args) { server_cmdline_t *server = NULL; @@ -542,6 +542,25 @@ out: return; } +static void +glfs_free_xlator_options (cmd_args_t *cmd_args) +{ + xlator_cmdline_option_t *xo = NULL; + xlator_cmdline_option_t *tmp_xo = NULL; + + if (!&(cmd_args->xlator_options)) + return; + + list_for_each_entry_safe (xo, tmp_xo, &cmd_args->xlator_options, + cmd_args) { + list_del_init (&xo->cmd_args); + GF_FREE (xo->volume); + GF_FREE (xo->key); + GF_FREE (xo->value); + GF_FREE (xo); + } +} + int pub_glfs_setfsuid (uid_t fsuid) { @@ -1092,6 +1111,8 @@ glusterfs_ctx_destroy (glusterfs_ctx_t *ctx) if (ctx->cmd_args.curr_server) glfs_free_volfile_servers (&ctx->cmd_args); + glfs_free_xlator_options (&ctx->cmd_args); + /* For all the graphs, crawl through the xlator_t structs and free * all its members except for the mem_acct member, * as GF_FREE will be referencing it. -- cgit