summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2019-04-05 12:33:55 +0530
committerAtin Mukherjee <amukherj@redhat.com>2019-04-15 06:06:02 +0000
commitc27eee869f319fa2afbce31f1ab332d381015256 (patch)
tree4d95e013e01bdfa57500e7c66ede776e7c06523a
parent8239efc76b56f1f4ce16bab263f7b355d8205820 (diff)
shd/mux: Fix coverity issues introduced by shd mux patch
CID 1400475: Null pointer dereferences (FORWARD_NULL) CID 1400474: Null pointer dereferences (FORWARD_NULL) CID 1400471: Code maintainability issues (UNUSED_VALUE) CID 1400470: Null pointer dereferences (FORWARD_NULL) CID 1400469: Memory - illegal accesses (USE_AFTER_FREE) CID 1400467: Code maintainability issues (UNUSED_VALUE) Change-Id: I0ca1c733be335c6e5844f44850f8066626ac40d4 updates: bz#789278 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
-rw-r--r--libglusterfs/src/graph.c21
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-shd-svc.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-svc-helper.c24
3 files changed, 36 insertions, 15 deletions
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 74b568441af..85b470dfeaa 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -1461,7 +1461,9 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj)
goto out;
parent_graph = ctx->active;
graph = volfile_obj->graph;
- if (graph && graph->first)
+ if (!graph)
+ goto out;
+ if (graph->first)
xl = graph->first;
last_xl = graph->last_xl;
@@ -1582,12 +1584,10 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
parent_graph->leaf_count += graph->leaf_count;
parent_graph->id++;
+ volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t);
if (!volfile_obj) {
- volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t);
- if (!volfile_obj) {
- ret = -1;
- goto out;
- }
+ ret = -1;
+ goto out;
}
graph->used = 1;
@@ -1632,6 +1632,7 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
{
glusterfs_graph_t *oldvolfile_graph = NULL;
glusterfs_graph_t *newvolfile_graph = NULL;
+ char vol_id[NAME_MAX + 1];
int ret = -1;
@@ -1663,6 +1664,9 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
glusterfs_graph_prepare(newvolfile_graph, ctx, newvolfile_graph->first);
if (!is_graph_topology_equal(oldvolfile_graph, newvolfile_graph)) {
+ ret = snprintf(vol_id, sizeof(vol_id), "%s", volfile_obj->vol_id);
+ if (ret < 0)
+ goto out;
ret = glusterfs_process_svc_detach(ctx, volfile_obj);
if (ret) {
gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, EINVAL,
@@ -1671,8 +1675,9 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
"old graph. Aborting the reconfiguration operation");
goto out;
}
- ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp,
- volfile_obj->vol_id, checksum);
+ volfile_obj = NULL;
+ ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id,
+ checksum);
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
index 47898434380..19eca9f2729 100644
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
@@ -101,6 +101,8 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
svc->conn.rpc = rpc_clnt_ref(mux_svc->rpc);
ret = snprintf(svc->conn.sockpath, sizeof(svc->conn.sockpath), "%s",
mux_conn->sockpath);
+ if (ret < 0)
+ goto out;
} else {
ret = mkdir_p(logdir, 0755, _gf_true);
if ((ret == -1) && (EEXIST != errno)) {
@@ -673,6 +675,10 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig)
glusterd_volinfo_ref(volinfo);
svc_proc->data = volinfo;
ret = glusterd_svc_stop(svc, sig);
+ if (ret) {
+ glusterd_volinfo_unref(volinfo);
+ goto out;
+ }
}
if (!empty && pid != -1) {
ret = glusterd_detach_svc(svc, volinfo, sig);
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
index e42703c0f41..02945b1e313 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
@@ -411,9 +411,14 @@ __gf_find_compatible_svc(gd_node_type daemon)
conf = THIS->private;
GF_VALIDATE_OR_GOTO("glusterd", conf, out);
- if (daemon == GD_NODE_SHD) {
- svc_procs = &conf->shd_procs;
- if (!svc_procs)
+ switch (daemon) {
+ case GD_NODE_SHD: {
+ svc_procs = &conf->shd_procs;
+ if (!svc_procs)
+ goto out;
+ } break;
+ default:
+ /* Add support for other client daemons here */
goto out;
}
@@ -540,11 +545,16 @@ __gf_find_compatible_svc_from_pid(gd_node_type daemon, pid_t pid)
if (!conf)
return NULL;
- if (daemon == GD_NODE_SHD) {
- svc_procs = &conf->shd_procs;
- if (!svc_proc)
+ switch (daemon) {
+ case GD_NODE_SHD: {
+ svc_procs = &conf->shd_procs;
+ if (!svc_procs)
+ return NULL;
+ } break;
+ default:
+ /* Add support for other client daemons here */
return NULL;
- } /* Can be moved to switch when mux is implemented for other daemon; */
+ }
cds_list_for_each_entry(svc_proc, svc_procs, svc_proc_list)
{