diff options
author | Sunny Kumar <sunkumar@redhat.com> | 2018-08-07 23:57:28 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-09-04 04:57:42 +0000 |
commit | 4cfbdfd0c851e4a5c6f4303a9141f34f8887b376 (patch) | |
tree | 7809b275c3d71e91181eea2c439bac3cc0edf61c | |
parent | 6d5d3d1d095a7df2b49b56246021d302a4b7d695 (diff) |
geo-rep : fix coverity issues in glusterd-geo-rep.c
This patch fixes RESOURCE_LEAK at line number 1344, 2088, 4819, 1347,
2092, 1608, 1612, 2284, 3837.
It also fixes FORWARD_NULL at line number 2955.
CID : 1175012, 1175014, 1210989, 1223042, 1223043, 1382381, 1382429,
1389120, 1389474, 1390452, 1356512.
Change-Id: I7de239944eb61073d208ecf3899999a1ea0c8e43
updates: bz#789278
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index ac07eb83bd8..8299971f6c7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -1341,6 +1341,15 @@ out: if (slave_buf) GF_FREE(slave_buf); + if (slave_vol) + GF_FREE (slave_vol); + + if (slave_url) + GF_FREE (slave_url); + + if (slave_host) + GF_FREE (slave_host); + gf_msg_debug (this->name, 0, "Returning %d.", ret); return ret; } @@ -1605,6 +1614,15 @@ out: if (errmsg) GF_FREE (errmsg); + if (slave_url) + GF_FREE (slave_url); + + if (slave_vol) + GF_FREE (slave_vol); + + if (slave_host) + GF_FREE (slave_host); + gf_msg_debug (this->name, 0, "Returning %d.", ret); return ret; } @@ -2085,7 +2103,17 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) ret = is_geo_rep_active (param->volinfo,slave, conf_path, ¶m->is_active); out: - GF_FREE(errmsg); + if (errmsg) + GF_FREE (errmsg); + + if (slave_vol) + GF_FREE (slave_vol); + + if (slave_url) + GF_FREE (slave_url); + if (slave_host) + GF_FREE (slave_host); + return ret; } @@ -2955,9 +2983,15 @@ get_slavehost_from_voluuid (dict_t *dict, char *key, data_t *value, void *data) /* get corresponding slave host for reference*/ slave_host = value->data; slave_host = strstr (slave_host, "://"); - if (slave_host) + if (slave_host) { slave_host += 3; - + } else { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SLAVE_VOL_PARSE_FAIL, + "Invalid slave_host format!"); + ret = -2; + goto out; + } /* To go past username in non-root geo-rep session */ tmp = strchr (slave_host, '@'); if (tmp) { @@ -3435,6 +3469,7 @@ out: if (ret && errmsg[0] != '\0') *op_errstr = gf_strdup (errmsg); + if (slave_url_buf) GF_FREE (slave_url_buf); @@ -4817,6 +4852,8 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave, out: gf_msg_debug (this->name, 0, "Returning %d", ret); + if (op_errstr) + GF_FREE (op_errstr); return ret; } |