summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-statedump.c
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2017-06-15 11:31:39 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-06-15 10:49:47 +0000
commitcd67c34e64e2c85a7d0abbce43a1db269a12be19 (patch)
tree44fb44fdb849012cba62edcb553a58d2f1b180e2 /xlators/mgmt/glusterd/src/glusterd-statedump.c
parentb1a6297ec323bfda27068b9579d2848cd8f48b0d (diff)
glusterd: fix crash on statedump when no volumes are started
pmap object is created when glusterd allocates a port for the very first time, however before that if someone tries to take statedump glusterd will crash. Solution : Add a NULL check before accessing pmap reference. Change-Id: I206b02e07a4717e68af2c6bf05fac55119353de8 BUG: 1461655 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: https://review.gluster.org/17549 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Samikshan Bairagya <samikshan@gmail.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-statedump.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-statedump.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c
index 7f806023566..d0a97053485 100644
--- a/xlators/mgmt/glusterd/src/glusterd-statedump.c
+++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c
@@ -239,18 +239,23 @@ glusterd_dump_priv (xlator_t *this)
/* Dump pmap data structure from base port to last alloc */
pmap = priv->pmap;
- for (port = pmap->base_port; port <= pmap->last_alloc;
- port++) {
- gf_proc_dump_build_key (key, "glusterd", "pmap_port");
- gf_proc_dump_write (key, "%d", port);
- gf_proc_dump_build_key (key, "glusterd",
- "pmap[%d].type", port);
- gf_proc_dump_write (key, "%d", pmap->ports[port].type);
- gf_proc_dump_build_key (key, "glusterd",
- "pmap[%d].brickname", port);
- gf_proc_dump_write (key, "%s",
- pmap->ports[port].brickname);
-
+ if (pmap) {
+ for (port = pmap->base_port; port <= pmap->last_alloc;
+ port++) {
+ gf_proc_dump_build_key (key, "glusterd",
+ "pmap_port");
+ gf_proc_dump_write (key, "%d", port);
+ gf_proc_dump_build_key (key, "glusterd",
+ "pmap[%d].type", port);
+ gf_proc_dump_write (key, "%d",
+ pmap->ports[port].type);
+ gf_proc_dump_build_key (key, "glusterd",
+ "pmap[%d].brickname",
+ port);
+ gf_proc_dump_write (key, "%s",
+ pmap->ports[port].brickname);
+
+ }
}
/* Dump client details */
glusterd_dump_client_details (priv);