From 7b160e36352a7f6da4a40e2278f58fba2fe60c88 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Thu, 20 Nov 2014 23:01:00 +0530 Subject: features/index: Perform closedir() in error paths to avoid fd leaks Change-Id: I7c8fc22ebe3c9cdf88e803e27c645cbad0012d16 BUG: 1166275 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/9167 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- xlators/features/index/src/index.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 8acddf088f3..fce57aba6b7 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -423,15 +423,13 @@ sync_base_indices (void *index_priv) } } - ret = closedir (xattrop_dir); - if (ret) - goto out; - ret = closedir (dir_base_holder); - if (ret) - goto out; ret = 0; out: + if (xattrop_dir) + closedir (xattrop_dir); + if (dir_base_holder) + closedir (dir_base_holder); return ret; } @@ -501,7 +499,6 @@ sync_base_indices_from_xattrop (xlator_t *this) if (ret) goto out; } - closedir (dir); } /*At this point of time we have index/base_indicies_holder directory @@ -519,9 +516,10 @@ sync_base_indices_from_xattrop (xlator_t *this) ret = synctask_new (this->ctx->env, sync_base_indices, base_indices_syncing_done,frame, priv); - - out: + if (dir) + closedir (dir); + return ret; } @@ -775,6 +773,7 @@ __index_fd_ctx_get (fd_t *fd, xlator_t *this, index_fd_ctx_t **ctx) ret = __fd_ctx_set (fd, this, (uint64_t)(long)fctx); if (ret) { + closedir (fctx->dir); GF_FREE (fctx); fctx = NULL; ret = -EINVAL; -- cgit