summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2018-08-24 09:42:12 -0700
committerAtin Mukherjee <amukherj@redhat.com>2018-08-27 02:41:01 +0000
commit43f037f6b10c5b1da1b56bc4e2ae4c4ae5c475ec (patch)
tree4ca54405e57f03263d8ea8f15d5ba6a9de7694e8
parent0e5ff35f1e328a61a85cf0e04ba125a6c72b4069 (diff)
mgmt/glusterd: Coverity fixes in glusterd-utils.c
Addresses the following CIDs: 1388821: Unchecked return value from sys_lremovexattr() in glusterd_check_and_set_brick_xattr() 1370957: Unused return value in glusterd_volume_tier_use_rsp_dict() 1370950: Memory leak in glusterd_get_global_options_for_all_vols() 1370946: Redundant gf_strdup() leading to a memory leak in glusterd_get_global_options_for_all_vols() Change-Id: I2ab58207bc43b40f004ee18463430a141126bf94 Updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index b52a1d287ef..40fd4bb83f2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -7741,7 +7741,13 @@ glusterd_check_and_set_brick_xattr (char *host, char *path, uuid_t uuid,
goto out;
} else {
- sys_lremovexattr (path, "trusted.glusterfs.test");
+ ret = sys_lremovexattr (path, "trusted.glusterfs.test");
+ if (ret) {
+ snprintf (msg, sizeof (msg), "Removing test extended"
+ " attribute failed, reason: %s",
+ strerror(errno));
+ goto out;
+ }
}
ret = glusterd_is_path_in_use (path, &in_use, op_errstr);
@@ -11236,9 +11242,13 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
if (ret) {
gf_msg_debug (this->name, errno,
"Missing remove-brick-id");
- } else
+ } else {
ret = dict_set_str (ctx_dict, GF_REMOVE_BRICK_TID_KEY,
task_id_str);
+ if (ret)
+ gf_msg_debug (this->name, errno,
+ "Failed to set remove brick task ID");
+ }
ret = 0;
@@ -13173,7 +13183,7 @@ glusterd_get_global_options_for_all_vols (rpcsvc_request_t *req, dict_t *ctx,
ALL_VOLUME_OPTION_CHECK ("all", _gf_true, key, ret, op_errstr, out);
for (i = 0; valid_all_vol_opts[i].option; i++) {
- allvolopt = gf_strdup (valid_all_vol_opts[i].option);
+ allvolopt = valid_all_vol_opts[i].option;
if (!all_opts && strcmp (key, allvolopt) != 0)
continue;
@@ -13226,6 +13236,7 @@ glusterd_get_global_options_for_all_vols (rpcsvc_request_t *req, dict_t *ctx,
if (need_free) {
GF_FREE (def_val);
+ need_free = _gf_false;
}
def_val = NULL;
allvolopt = NULL;
@@ -13248,6 +13259,11 @@ out:
if (*op_errstr == NULL)
*op_errstr = gf_strdup (err_str);
}
+
+ if (ret && need_free) {
+ GF_FREE (def_val);
+ }
+
gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;