summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorSantosh Kumar Pradhan <spradhan@redhat.com>2014-02-10 20:52:57 +0530
committerAnand Avati <avati@redhat.com>2014-02-12 17:40:31 -0800
commit1b88d86a660a5f4e007fb229d79c54666ce04ffb (patch)
treecef08f6419518bb0141773946276e41067b6cf97 /rpc
parent547ee245dac4f2689a0f3f8f66635e0195489602 (diff)
glusterd: Fix possible leaks on failure code path
Fix the memory leaks in socket and glusterd in failure code paths reported by Coverity. CIDs: 1124777, 1124781, 124782 Change-Id: I63472c6b5900f308f19e64fc93bf7ed2f7b06ade BUG: 789278 Signed-off-by: Santosh Kumar Pradhan <spradhan@redhat.com> Reviewed-on: http://review.gluster.org/6954 Reviewed-by: Raghavendra Talur <rtalur@redhat.com> 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-transport/socket/src/socket.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 490fe8a7e98..e3d97f7c839 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2491,8 +2491,10 @@ socket_server_event_handler (int fd, int idx, void *data,
new_trans = GF_CALLOC (1, sizeof (*new_trans),
gf_common_mt_rpc_trans_t);
- if (!new_trans)
+ if (!new_trans) {
+ close (new_sock);
goto unlock;
+ }
ret = pthread_mutex_init(&new_trans->lock, NULL);
if (ret == -1) {
@@ -2500,6 +2502,7 @@ socket_server_event_handler (int fd, int idx, void *data,
"pthread_mutex_init() failed: %s",
strerror (errno));
close (new_sock);
+ GF_FREE (new_trans);
goto unlock;
}
@@ -2520,6 +2523,8 @@ socket_server_event_handler (int fd, int idx, void *data,
"getsockname on %d failed (%s)",
new_sock, strerror (errno));
close (new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
@@ -2527,6 +2532,8 @@ socket_server_event_handler (int fd, int idx, void *data,
ret = socket_init(new_trans);
if (ret != 0) {
close(new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
new_trans->ops = this->ops;
@@ -2549,6 +2556,8 @@ socket_server_event_handler (int fd, int idx, void *data,
gf_log(this->name,GF_LOG_ERROR,
"server setup failed");
close(new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
}
@@ -2562,6 +2571,8 @@ socket_server_event_handler (int fd, int idx, void *data,
new_sock, strerror (errno));
close (new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
}
@@ -2600,6 +2611,8 @@ socket_server_event_handler (int fd, int idx, void *data,
if (ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
"failed to register the socket with event");
+ close (new_sock);
+ rpc_transport_unref (new_trans);
goto unlock;
}