summaryrefslogtreecommitdiffstats
path: root/glusterfsd
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-06-05 14:15:54 +0530
committerAnand Avati <avati@redhat.com>2012-06-05 10:45:10 -0700
commit6eee473eba94697953e8b3e1b04fe5ef1de5f474 (patch)
treed435b4f4186690907c39a28257f3707ea86bbeb1 /glusterfsd
parent04fd2972fe8a9b9568ac781ba7677f13fdce0f57 (diff)
core: coverity fixes (mostly resource leak fixes)
currently working on obvious resource leak reports in coverity Change-Id: I261f4c578987b16da399ab5a504ad0fda0b176b1 Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 789278 Reviewed-on: http://review.gluster.com/3265 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'glusterfsd')
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c3
-rw-r--r--glusterfsd/src/glusterfsd.c60
2 files changed, 50 insertions, 13 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index d8582aa..073ed54 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -1521,6 +1521,9 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp)
ret = 0;
out:
+ if (oldvolfile_fp)
+ fclose (oldvolfile_fp);
+
return ret;
}
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index ebd12bf..c6285b2 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -1025,6 +1025,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
cmd_args_t *cmd_args = NULL;
struct rlimit lim = {0, };
call_pool_t *pool = NULL;
+ int ret = -1;
xlator_mem_acct_init (THIS, gfd_mt_end);
@@ -1032,7 +1033,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
if (!ctx->process_uuid) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs uuid generation failed");
- return -1;
+ goto out;
}
ctx->page_size = 128 * GF_UNIT_KB;
@@ -1041,14 +1042,14 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
if (!ctx->iobuf_pool) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs iobuf pool creation failed");
- return -1;
+ goto out;
}
ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
if (!ctx->event_pool) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs event pool creation failed");
- return -1;
+ goto out;
}
pool = GF_CALLOC (1, sizeof (call_pool_t),
@@ -1056,7 +1057,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
if (!pool) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs call pool creation failed");
- return -1;
+ goto out;
}
/* frame_mem_pool size 112 * 4k */
@@ -1064,21 +1065,21 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
if (!pool->frame_mem_pool) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs frame pool creation failed");
- return -1;
+ goto out;
}
/* stack_mem_pool size 256 * 1024 */
pool->stack_mem_pool = mem_pool_new (call_stack_t, 1024);
if (!pool->stack_mem_pool) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs stack pool creation failed");
- return -1;
+ goto out;
}
ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024);
if (!ctx->stub_mem_pool) {
gf_log ("", GF_LOG_CRITICAL,
"ERROR: glusterfs stub pool creation failed");
- return -1;
+ goto out;
}
ctx->dict_pool = mem_pool_new (dict_t, GF_MEMPOOL_COUNT_OF_DICT_T);
@@ -1123,7 +1124,35 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
lim.rlim_max = RLIM_INFINITY;
setrlimit (RLIMIT_CORE, &lim);
- return 0;
+ ret = 0;
+out:
+
+ if (ret && pool) {
+
+ if (pool->frame_mem_pool)
+ mem_pool_destroy (pool->frame_mem_pool);
+
+ if (pool->stack_mem_pool)
+ mem_pool_destroy (pool->stack_mem_pool);
+
+ GF_FREE (pool);
+ }
+
+ if (ret && ctx) {
+ if (ctx->stub_mem_pool)
+ mem_pool_destroy (ctx->stub_mem_pool);
+
+ if (ctx->dict_pool)
+ mem_pool_destroy (ctx->dict_pool);
+
+ if (ctx->dict_data_pool)
+ mem_pool_destroy (ctx->dict_data_pool);
+
+ if (ctx->dict_pair_pool)
+ mem_pool_destroy (ctx->dict_pair_pool);
+ }
+
+ return ret;
}
static int
@@ -1273,7 +1302,7 @@ int
glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)
{
cmd_args_t *cmd_args = NULL;
- int ret = 0;
+ int ret = -1;
FILE *pidfp = NULL;
cmd_args = &ctx->cmd_args;
@@ -1286,7 +1315,7 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)
gf_log ("glusterfsd", GF_LOG_ERROR,
"pidfile %s error (%s)",
cmd_args->pid_file, strerror (errno));
- return -1;
+ goto out;
}
ret = lockf (fileno (pidfp), F_TLOCK, 0);
@@ -1294,7 +1323,7 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)
gf_log ("glusterfsd", GF_LOG_ERROR,
"pidfile %s lock error (%s)",
cmd_args->pid_file, strerror (errno));
- return ret;
+ goto out;
}
gf_log ("glusterfsd", GF_LOG_TRACE,
@@ -1306,12 +1335,17 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)
gf_log ("glusterfsd", GF_LOG_ERROR,
"pidfile %s unlock error (%s)",
cmd_args->pid_file, strerror (errno));
- return ret;
+ goto out;
}
ctx->pidfp = pidfp;
- return 0;
+ ret = 0;
+out:
+ if (ret && pidfp)
+ fclose (pidfp);
+
+ return ret;
}