summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-09-05 18:16:37 +0530
committerN Balachandran <nbalacha@redhat.com>2018-09-06 04:51:27 +0000
commit889040e20d86da14aab372203ebaa91dda5db6f2 (patch)
tree19ac205c4b64961fc758772f5768b4580249d394
parent2b95d2c0be20a62279bbfebc17457004aca0988f (diff)
cluster/dht: Initialise pointers to null
Use calloc in dht_layouts_init so to as to prevent dht_init from attempting to free invalid memory in case of failure. There are other ways to do this (set first failure to null and break there when cleaning up) but I prefer having all pointers initialized to null. This is a one time operation so it should not be too expensive. Change-Id: Ie22246047448f1cae971d48fa5aaf2efcaeb42c0 fixes: bz#1625643 Signed-off-by: N Balachandran <nbalacha@redhat.com>
-rw-r--r--xlators/cluster/dht/src/dht-layout.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index 6d9d4e693ff..97b98e01451 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -201,8 +201,8 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf)
if (!conf)
goto out;
- conf->file_layouts = GF_MALLOC (conf->subvolume_cnt
- * sizeof (dht_layout_t *),
+ conf->file_layouts = GF_CALLOC (conf->subvolume_cnt,
+ sizeof (dht_layout_t *),
gf_dht_mt_dht_layout_t);
if (!conf->file_layouts) {
goto out;