From aaf7cd3c4059167b0f2ba821d14362a977f1d58c Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sun, 15 Mar 2015 14:16:56 +0100 Subject: nfs: improve cleanup of 'struct exports_file' to prevent memory leak BUG: 1143880 Change-Id: I359470a1edb935e206eeeecd4de7022530fb397a Reported-by: Vijay Bellur Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/9882 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/nfs/server/src/exports.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'xlators/nfs/server/src/exports.c') diff --git a/xlators/nfs/server/src/exports.c b/xlators/nfs/server/src/exports.c index 3f704bdf9ce..793e020dd1f 100644 --- a/xlators/nfs/server/src/exports.c +++ b/xlators/nfs/server/src/exports.c @@ -91,11 +91,12 @@ _exports_file_init () goto free_and_out; } - - goto out; free_and_out: + if (file->exports_dict) + dict_unref (file->exports_dict); + GF_FREE (file); file = NULL; out: @@ -141,10 +142,21 @@ out: void exp_file_deinit (struct exports_file *expfile) { - if (!expfile || !expfile->exports_dict) + if (!expfile) goto out; - dict_foreach (expfile->exports_dict, _exp_file_dict_destroy, NULL); + if (expfile->exports_dict) { + dict_foreach (expfile->exports_dict, _exp_file_dict_destroy, + NULL); + dict_unref (expfile->exports_dict); + } + + if (expfile->exports_map) { + dict_foreach (expfile->exports_map, _exp_file_dict_destroy, + NULL); + dict_unref (expfile->exports_map); + } + GF_FREE (expfile->filename); GF_FREE (expfile); out: -- cgit