|
|
233933 |
From 0021a4bbc9af2bfe28d4a79f76c3cd33f23dd118 Mon Sep 17 00:00:00 2001
|
|
|
233933 |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
233933 |
Date: Fri, 5 Apr 2019 12:33:55 +0530
|
|
|
233933 |
Subject: [PATCH 101/124] shd/mux: Fix coverity issues introduced by shd mux
|
|
|
233933 |
patch
|
|
|
233933 |
|
|
|
233933 |
CID 1400475: Null pointer dereferences (FORWARD_NULL)
|
|
|
233933 |
CID 1400474: Null pointer dereferences (FORWARD_NULL)
|
|
|
233933 |
CID 1400471: Code maintainability issues (UNUSED_VALUE)
|
|
|
233933 |
CID 1400470: Null pointer dereferences (FORWARD_NULL)
|
|
|
233933 |
CID 1400469: Memory - illegal accesses (USE_AFTER_FREE)
|
|
|
233933 |
CID 1400467: Code maintainability issues (UNUSED_VALUE)
|
|
|
233933 |
|
|
|
233933 |
Backport of: https://review.gluster.org/#/c/glusterfs/+/22514/
|
|
|
233933 |
|
|
|
233933 |
>Change-Id: I0ca1c733be335c6e5844f44850f8066626ac40d4
|
|
|
233933 |
>updates: bz#789278
|
|
|
233933 |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
233933 |
|
|
|
233933 |
Change-Id: I0425efca9ab5a95801eff9e99259219449a16380
|
|
|
233933 |
BUG: 1471742
|
|
|
233933 |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
233933 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/167832
|
|
|
233933 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
233933 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
233933 |
---
|
|
|
233933 |
libglusterfs/src/graph.c | 21 +++++++++++++--------
|
|
|
233933 |
xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 6 ++++++
|
|
|
233933 |
xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 24 +++++++++++++++++-------
|
|
|
233933 |
3 files changed, 36 insertions(+), 15 deletions(-)
|
|
|
233933 |
|
|
|
233933 |
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
|
|
|
233933 |
index a492dd8..4c8b02d 100644
|
|
|
233933 |
--- a/libglusterfs/src/graph.c
|
|
|
233933 |
+++ b/libglusterfs/src/graph.c
|
|
|
233933 |
@@ -1470,7 +1470,9 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj)
|
|
|
233933 |
goto out;
|
|
|
233933 |
parent_graph = ctx->active;
|
|
|
233933 |
graph = volfile_obj->graph;
|
|
|
233933 |
- if (graph && graph->first)
|
|
|
233933 |
+ if (!graph)
|
|
|
233933 |
+ goto out;
|
|
|
233933 |
+ if (graph->first)
|
|
|
233933 |
xl = graph->first;
|
|
|
233933 |
|
|
|
233933 |
last_xl = graph->last_xl;
|
|
|
233933 |
@@ -1591,12 +1593,10 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
|
|
|
233933 |
parent_graph->leaf_count += graph->leaf_count;
|
|
|
233933 |
parent_graph->id++;
|
|
|
233933 |
|
|
|
233933 |
+ volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t);
|
|
|
233933 |
if (!volfile_obj) {
|
|
|
233933 |
- volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t);
|
|
|
233933 |
- if (!volfile_obj) {
|
|
|
233933 |
- ret = -1;
|
|
|
233933 |
- goto out;
|
|
|
233933 |
- }
|
|
|
233933 |
+ ret = -1;
|
|
|
233933 |
+ goto out;
|
|
|
233933 |
}
|
|
|
233933 |
|
|
|
233933 |
graph->used = 1;
|
|
|
233933 |
@@ -1641,6 +1641,7 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
|
|
|
233933 |
{
|
|
|
233933 |
glusterfs_graph_t *oldvolfile_graph = NULL;
|
|
|
233933 |
glusterfs_graph_t *newvolfile_graph = NULL;
|
|
|
233933 |
+ char vol_id[NAME_MAX + 1];
|
|
|
233933 |
|
|
|
233933 |
int ret = -1;
|
|
|
233933 |
|
|
|
233933 |
@@ -1672,6 +1673,9 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
|
|
|
233933 |
glusterfs_graph_prepare(newvolfile_graph, ctx, newvolfile_graph->first);
|
|
|
233933 |
|
|
|
233933 |
if (!is_graph_topology_equal(oldvolfile_graph, newvolfile_graph)) {
|
|
|
233933 |
+ ret = snprintf(vol_id, sizeof(vol_id), "%s", volfile_obj->vol_id);
|
|
|
233933 |
+ if (ret < 0)
|
|
|
233933 |
+ goto out;
|
|
|
233933 |
ret = glusterfs_process_svc_detach(ctx, volfile_obj);
|
|
|
233933 |
if (ret) {
|
|
|
233933 |
gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, EINVAL,
|
|
|
233933 |
@@ -1680,8 +1684,9 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
|
|
|
233933 |
"old graph. Aborting the reconfiguration operation");
|
|
|
233933 |
goto out;
|
|
|
233933 |
}
|
|
|
233933 |
- ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp,
|
|
|
233933 |
- volfile_obj->vol_id, checksum);
|
|
|
233933 |
+ volfile_obj = NULL;
|
|
|
233933 |
+ ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id,
|
|
|
233933 |
+ checksum);
|
|
|
233933 |
goto out;
|
|
|
233933 |
}
|
|
|
233933 |
|
|
|
233933 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
233933 |
index 937ea30..04a4b2e 100644
|
|
|
233933 |
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
233933 |
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
|
|
|
233933 |
@@ -101,6 +101,8 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
|
|
|
233933 |
svc->conn.rpc = rpc_clnt_ref(mux_svc->rpc);
|
|
|
233933 |
ret = snprintf(svc->conn.sockpath, sizeof(svc->conn.sockpath), "%s",
|
|
|
233933 |
mux_conn->sockpath);
|
|
|
233933 |
+ if (ret < 0)
|
|
|
233933 |
+ goto out;
|
|
|
233933 |
} else {
|
|
|
233933 |
ret = mkdir_p(logdir, 0755, _gf_true);
|
|
|
233933 |
if ((ret == -1) && (EEXIST != errno)) {
|
|
|
233933 |
@@ -663,6 +665,10 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig)
|
|
|
233933 |
glusterd_volinfo_ref(volinfo);
|
|
|
233933 |
svc_proc->data = volinfo;
|
|
|
233933 |
ret = glusterd_svc_stop(svc, sig);
|
|
|
233933 |
+ if (ret) {
|
|
|
233933 |
+ glusterd_volinfo_unref(volinfo);
|
|
|
233933 |
+ goto out;
|
|
|
233933 |
+ }
|
|
|
233933 |
}
|
|
|
233933 |
if (!empty && pid != -1) {
|
|
|
233933 |
ret = glusterd_detach_svc(svc, volinfo, sig);
|
|
|
233933 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
|
|
|
233933 |
index e42703c..02945b1 100644
|
|
|
233933 |
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
|
|
|
233933 |
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
|
|
|
233933 |
@@ -411,9 +411,14 @@ __gf_find_compatible_svc(gd_node_type daemon)
|
|
|
233933 |
conf = THIS->private;
|
|
|
233933 |
GF_VALIDATE_OR_GOTO("glusterd", conf, out);
|
|
|
233933 |
|
|
|
233933 |
- if (daemon == GD_NODE_SHD) {
|
|
|
233933 |
- svc_procs = &conf->shd_procs;
|
|
|
233933 |
- if (!svc_procs)
|
|
|
233933 |
+ switch (daemon) {
|
|
|
233933 |
+ case GD_NODE_SHD: {
|
|
|
233933 |
+ svc_procs = &conf->shd_procs;
|
|
|
233933 |
+ if (!svc_procs)
|
|
|
233933 |
+ goto out;
|
|
|
233933 |
+ } break;
|
|
|
233933 |
+ default:
|
|
|
233933 |
+ /* Add support for other client daemons here */
|
|
|
233933 |
goto out;
|
|
|
233933 |
}
|
|
|
233933 |
|
|
|
233933 |
@@ -540,11 +545,16 @@ __gf_find_compatible_svc_from_pid(gd_node_type daemon, pid_t pid)
|
|
|
233933 |
if (!conf)
|
|
|
233933 |
return NULL;
|
|
|
233933 |
|
|
|
233933 |
- if (daemon == GD_NODE_SHD) {
|
|
|
233933 |
- svc_procs = &conf->shd_procs;
|
|
|
233933 |
- if (!svc_proc)
|
|
|
233933 |
+ switch (daemon) {
|
|
|
233933 |
+ case GD_NODE_SHD: {
|
|
|
233933 |
+ svc_procs = &conf->shd_procs;
|
|
|
233933 |
+ if (!svc_procs)
|
|
|
233933 |
+ return NULL;
|
|
|
233933 |
+ } break;
|
|
|
233933 |
+ default:
|
|
|
233933 |
+ /* Add support for other client daemons here */
|
|
|
233933 |
return NULL;
|
|
|
233933 |
- } /* Can be moved to switch when mux is implemented for other daemon; */
|
|
|
233933 |
+ }
|
|
|
233933 |
|
|
|
233933 |
cds_list_for_each_entry(svc_proc, svc_procs, svc_proc_list)
|
|
|
233933 |
{
|
|
|
233933 |
--
|
|
|
233933 |
1.8.3.1
|
|
|
233933 |
|