summaryrefslogtreecommitdiffstats
path: root/rpc
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 /rpc
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 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpc-transport.c20
-rw-r--r--rpc/rpc-lib/src/rpc-transport.h1
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c16
-rw-r--r--rpc/rpc-transport/socket/src/socket.c2
4 files changed, 28 insertions, 11 deletions
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c
index 8da898b61c3..d0e7834e8d7 100644
--- a/rpc/rpc-lib/src/rpc-transport.c
+++ b/rpc/rpc-lib/src/rpc-transport.c
@@ -257,6 +257,8 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
goto fail;
}
+ trans->dl_handle = handle;
+
trans->ops = dlsym (handle, "tops");
if (trans->ops == NULL) {
gf_log ("rpc-transport", GF_LOG_ERROR,
@@ -319,9 +321,11 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name)
return_trans = trans;
- if (name) {
+ if (name)
GF_FREE (name);
- }
+
+ if (vol_opt)
+ GF_FREE (vol_opt);
return return_trans;
@@ -331,12 +335,17 @@ fail:
GF_FREE (trans->name);
}
+ if (trans->dl_handle)
+ dlclose (trans->dl_handle);
+
GF_FREE (trans);
}
- if (name) {
+ if (name)
GF_FREE (name);
- }
+
+ if (vol_opt)
+ GF_FREE (vol_opt);
return NULL;
}
@@ -426,6 +435,9 @@ rpc_transport_destroy (rpc_transport_t *this)
if (this->name)
GF_FREE (this->name);
+ if (this->dl_handle)
+ dlclose (this->dl_handle);
+
GF_FREE (this);
fail:
return ret;
diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h
index d9ab30dd81e..91d802220e2 100644
--- a/rpc/rpc-lib/src/rpc-transport.h
+++ b/rpc/rpc-lib/src/rpc-transport.h
@@ -205,6 +205,7 @@ struct rpc_transport {
struct list_head list;
int bind_insecure;
+ void *dl_handle; /* handle of dlopen() */
};
struct rpc_transport_ops {
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 98cc88d63b1..ee9e1c72507 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -1502,6 +1502,7 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name)
}
GF_FREE (transport_name);
+ transport_name = NULL;
count++;
}
@@ -1513,17 +1514,17 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name)
transport_type = NULL;
out:
- if (str != NULL) {
+ if (str)
GF_FREE (str);
- }
- if (transport_type != NULL) {
+ if (transport_type)
GF_FREE (transport_type);
- }
- if (tmp != NULL) {
+ if (tmp)
GF_FREE (tmp);
- }
+
+ if (transport_name)
+ GF_FREE (transport_name);
return count;
}
@@ -2398,6 +2399,9 @@ rpcsvc_transport_privport_check (rpcsvc_t *svc, char *volname,
" allowed");
err:
+ if (srchstr)
+ GF_FREE (srchstr);
+
return ret;
}
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index d193c93cea0..cf30e7d7d50 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -314,7 +314,7 @@ __socket_server_bind (rpc_transport_t *this)
memcpy (&unix_addr, SA (&this->myinfo.sockaddr),
this->myinfo.sockaddr_len);
reuse_check_sock = socket (AF_UNIX, SOCK_STREAM, 0);
- if (reuse_check_sock > 0) {
+ if (reuse_check_sock >= 0) {
ret = connect (reuse_check_sock, SA (&unix_addr),
this->myinfo.sockaddr_len);
if ((ret == -1) && (ECONNREFUSED == errno)) {