summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2019-04-24 22:02:51 +0530
committerAtin Mukherjee <amukherj@redhat.com>2019-04-25 06:39:16 +0000
commitc827682e4df44ec6aaae3780c325568fb43053ff (patch)
treeac7ddc6c908f18f9c163dbd19302d6274b7111d3 /xlators/mgmt/glusterd
parent647e2d3a9fbe36f2fbf062feda53b7cb6aa4830b (diff)
glusterd: coverity fixes
Addresses the following: * CID 1124776: Resource leaks (RESOURCE_LEAK) - Variable "aa" going out of scope leaks the storage it points to in glusterd-volgen.c * Bunch of CHECKED_RETURN defects in the callers of synctask_barrier_init * CID 1400755: Error handling issues (CHECKED_RETURN) - Calling "gf_is_service_running" without checking return value in xlators/mgmt/glusterd/src/glusterd-shd-svc.c: 671 in glusterd_shdsvc_stop() * CID 1400745: Memory - illegal accesses (USE_AFTER_FREE) - Dereferencing freed pointer "volinfo" in /xlators/mgmt/glusterd/src/glusterd-shd-svc.c: 460 in glusterd_shdsvc_start() * CID 1400742: Program hangs (LOCK) - adding annotation to fix this false positive Updates: bz#789278 Change-Id: I02f16e7eeb8c5cf72f7d0b29d00df4f03b3718b3 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.c24
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-shd-svc.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c5
5 files changed, 50 insertions, 13 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 678425a19a8..4b069574bbd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -3288,6 +3288,12 @@ glusterd_friend_remove(uuid_t uuid, char *hostname)
ret = glusterd_peerinfo_cleanup(peerinfo);
out:
gf_msg_debug(THIS->name, 0, "returning %d", ret);
+ /* We don't need to do a mutex unlock of peerinfo->delete_lock as the same
+ * will be anyway destroyed within glusterd_peerinfo_cleanup, coverity
+ * though cries about it
+ */
+ /* coverity[LOCK] */
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
index 61ad66ee6ec..f5f44f6b2a9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
@@ -757,7 +757,10 @@ glusterd_mgmt_v3_initiate_lockdown(glusterd_op_t op, dict_t *dict,
/* Sending mgmt_v3 lock req to other nodes in the cluster */
gd_syncargs_init(&args, NULL);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
RCU_READ_LOCK;
@@ -1107,7 +1110,10 @@ glusterd_mgmt_v3_pre_validate(glusterd_op_t op, dict_t *req_dict,
/* Sending Pre Validation req to other nodes in the cluster */
gd_syncargs_init(&args, req_dict);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
RCU_READ_LOCK;
@@ -1457,7 +1463,10 @@ glusterd_mgmt_v3_brick_op(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
/* Sending brick op req to other nodes in the cluster */
gd_syncargs_init(&args, op_ctx);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
RCU_READ_LOCK;
@@ -1721,7 +1730,9 @@ glusterd_mgmt_v3_commit(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
/* Sending commit req to other nodes in the cluster */
gd_syncargs_init(&args, op_ctx);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
peer_cnt = 0;
RCU_READ_LOCK;
@@ -1962,7 +1973,10 @@ glusterd_mgmt_v3_post_validate(glusterd_op_t op, int32_t op_ret, dict_t *dict,
/* Sending Post Validation req to other nodes in the cluster */
gd_syncargs_init(&args, req_dict);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
RCU_READ_LOCK;
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
index a9eab42a46c..3e257e63c18 100644
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
@@ -456,11 +456,11 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
/* Unref will happen from glusterd_svc_attach_cbk */
ret = glusterd_attach_svc(svc, volinfo, flags);
if (ret) {
- glusterd_volinfo_unref(volinfo);
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL,
"Failed to attach shd svc(volume=%s) to pid=%d. Starting"
"a new process",
volinfo->volname, glusterd_proc_get_pid(&svc->proc));
+ glusterd_volinfo_unref(volinfo);
ret = glusterd_recover_shd_attach_failure(volinfo, svc, flags);
}
goto out;
@@ -668,7 +668,9 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig)
glusterd_volinfo_ref(volinfo);
pthread_mutex_lock(&conf->attach_lock);
{
- gf_is_service_running(svc->proc.pidfile, &pid);
+ if (!gf_is_service_running(svc->proc.pidfile, &pid)) {
+ gf_msg_debug(THIS->name, 0, "shd isn't running");
+ }
cds_list_del_init(&svc->mux_svc);
empty = cds_list_empty(&svc_proc->svcs);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index 9bab2cfd54c..60a25ad974a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -1191,7 +1191,12 @@ gd_lock_op_phase(glusterd_conf_t *conf, glusterd_op_t op, dict_t *op_ctx,
struct syncargs args = {0};
this = THIS;
- synctask_barrier_init((&args));
+ GF_VALIDATE_OR_GOTO("glusterd", this, out);
+
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
RCU_READ_LOCK;
@@ -1321,7 +1326,10 @@ stage_done:
}
gd_syncargs_init(&args, aggr_dict);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
RCU_READ_LOCK;
@@ -1449,7 +1457,10 @@ commit_done:
}
gd_syncargs_init(&args, op_ctx);
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
origin_glusterd = is_origin_glusterd(req_dict);
@@ -1541,7 +1552,10 @@ gd_unlock_op_phase(glusterd_conf_t *conf, glusterd_op_t op, int *op_ret,
goto out;
}
- synctask_barrier_init((&args));
+ ret = synctask_barrier_init((&args));
+ if (ret)
+ goto out;
+
peer_cnt = 0;
if (cluster_lock) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 493edb101b6..69298adc8cb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -4726,9 +4726,10 @@ nfs_option_handler(volgen_graph_t *graph, struct volopt_map_entry *vme,
if (ret != -1) {
ret = gf_canonicalize_path(vme->value);
- if (ret)
+ if (ret) {
+ GF_FREE(aa);
return -1;
-
+ }
ret = xlator_set_option(xl, aa, ret, vme->value);
GF_FREE(aa);
}