|
|
887953 |
From ff98fc7a53b51b14c64c47def854d98cbd1f3ca0 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Date: Mon, 21 Jan 2019 20:52:36 +0530
|
|
|
887953 |
Subject: [PATCH 508/508] glusterd: Resolve multiple leaks in glusterd code
|
|
|
887953 |
path
|
|
|
887953 |
|
|
|
887953 |
In gluster get-state volumeoptions command there was some amount of leak
|
|
|
887953 |
observed. This fix resolves the identified leaks.
|
|
|
887953 |
|
|
|
887953 |
> Change-Id: Ibde5743d1136fa72c531d48bb1b0b5da0c0b82a1
|
|
|
887953 |
> fixes: bz#1667779
|
|
|
887953 |
> (Cherry picked from commit 5903111ad21cb937258c0fda24ea7dec466347b4)
|
|
|
887953 |
> (Cherry picked from commit 4d3be307293b63c74398dfa715e9920cf356f083)
|
|
|
887953 |
> (Cherry picked from commit 2b7b6ff28fa92335613d0b5715acd552cfcfd759)
|
|
|
887953 |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/21823/)
|
|
|
887953 |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/20888/)
|
|
|
887953 |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22064/)
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I7bf3ed61770511c73975ad7b0d4fe97619c9864a
|
|
|
887953 |
BUG: 1667169
|
|
|
887953 |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/161128
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd-handler.c | 13 ++++++++++---
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd-utils.c | 11 +++++++++++
|
|
|
887953 |
2 files changed, 21 insertions(+), 3 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
887953 |
index d8e333510..81b1c029d 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
887953 |
@@ -1808,6 +1808,8 @@ out:
|
|
|
887953 |
glusterd_to_cli (req, &rsp, NULL, 0, NULL,
|
|
|
887953 |
(xdrproc_t)xdr_gf_cli_rsp, dict);
|
|
|
887953 |
|
|
|
887953 |
+ GF_FREE(rsp.dict.dict_val);
|
|
|
887953 |
+
|
|
|
887953 |
return 0;
|
|
|
887953 |
}
|
|
|
887953 |
int
|
|
|
887953 |
@@ -1871,6 +1873,7 @@ out:
|
|
|
887953 |
if (dict)
|
|
|
887953 |
dict_unref (dict);
|
|
|
887953 |
|
|
|
887953 |
+ GF_FREE(rsp.dict.dict_val);
|
|
|
887953 |
glusterd_friend_sm ();
|
|
|
887953 |
glusterd_op_sm ();
|
|
|
887953 |
|
|
|
887953 |
@@ -4991,6 +4994,7 @@ out:
|
|
|
887953 |
|
|
|
887953 |
glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
|
|
|
887953 |
(xdrproc_t)xdr_gf_cli_rsp);
|
|
|
887953 |
+ GF_FREE(rsp.dict.dict_val);
|
|
|
887953 |
return ret;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
@@ -5221,7 +5225,7 @@ glusterd_print_snapinfo_by_vol (FILE *fp, glusterd_volinfo_t *volinfo, int volco
|
|
|
887953 |
fprintf (fp, "Volume%d.snapshot%d.name: %s\n",
|
|
|
887953 |
volcount, snapcount, snapinfo->snapname);
|
|
|
887953 |
fprintf (fp, "Volume%d.snapshot%d.id: %s\n", volcount, snapcount,
|
|
|
887953 |
- gf_strdup (uuid_utoa (snapinfo->snap_id)));
|
|
|
887953 |
+ uuid_utoa (snapinfo->snap_id));
|
|
|
887953 |
fprintf (fp, "Volume%d.snapshot%d.time: %s\n",
|
|
|
887953 |
volcount, snapcount, timestr);
|
|
|
887953 |
|
|
|
887953 |
@@ -5494,6 +5498,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
|
|
887953 |
GD_MSG_DICT_GET_FAILED, "%s", err_str);
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
+ GF_FREE (odir);
|
|
|
887953 |
ret = -1;
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
@@ -5528,7 +5533,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
|
|
887953 |
GF_FREE (odir);
|
|
|
887953 |
GF_FREE (filename);
|
|
|
887953 |
|
|
|
887953 |
- ret = dict_set_str (dict, "ofilepath", ofilepath);
|
|
|
887953 |
+ ret = dict_set_dynstr (dict, "ofilepath", ofilepath);
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
887953 |
GD_MSG_DICT_SET_FAILED, "Unable to set output path");
|
|
|
887953 |
@@ -5568,6 +5573,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
|
|
887953 |
GD_MSG_VOL_OPTS_IMPORT_FAIL, "Failed to "
|
|
|
887953 |
"fetch the value of all volume options "
|
|
|
887953 |
"for volume %s", volinfo->volname);
|
|
|
887953 |
+ dict_unref (vol_all_opts);
|
|
|
887953 |
continue;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
@@ -5942,7 +5948,7 @@ out:
|
|
|
887953 |
&rsp.dict.dict_len);
|
|
|
887953 |
glusterd_to_cli (req, &rsp, NULL, 0, NULL,
|
|
|
887953 |
(xdrproc_t)xdr_gf_cli_rsp, dict);
|
|
|
887953 |
-
|
|
|
887953 |
+ GF_FREE(rsp.dict.dict_val);
|
|
|
887953 |
return ret;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
@@ -5986,6 +5992,7 @@ __glusterd_handle_get_state (rpcsvc_request_t *req)
|
|
|
887953 |
"unserialize req-buffer to dictionary");
|
|
|
887953 |
snprintf (err_str, sizeof (err_str), "Unable to decode"
|
|
|
887953 |
" the command");
|
|
|
887953 |
+ free (cli_req.dict.dict_val);
|
|
|
887953 |
goto out;
|
|
|
887953 |
} else {
|
|
|
887953 |
dict->extra_stdfree = cli_req.dict.dict_val;
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
887953 |
index 0fe56ebbc..e21ec4e5d 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
887953 |
@@ -13125,6 +13125,7 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
|
|
|
887953 |
char *def_val = NULL;
|
|
|
887953 |
char dict_key[50] = {0,};
|
|
|
887953 |
gf_boolean_t key_found = _gf_false;
|
|
|
887953 |
+ gf_boolean_t get_value_vme = _gf_false;
|
|
|
887953 |
glusterd_conf_t *priv = NULL;
|
|
|
887953 |
dict_t *vol_dict = NULL;
|
|
|
887953 |
|
|
|
887953 |
@@ -13149,6 +13150,7 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
|
|
|
887953 |
if (!all_opts && strcmp (vme->key, input_key))
|
|
|
887953 |
continue;
|
|
|
887953 |
key_found = _gf_true;
|
|
|
887953 |
+ get_value_vme = _gf_false;
|
|
|
887953 |
/* First look for the key in the priv->opts for global option
|
|
|
887953 |
* and then into vol_dict, if its not present then look for
|
|
|
887953 |
* translator default value */
|
|
|
887953 |
@@ -13164,6 +13166,7 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
|
|
|
887953 |
} else {
|
|
|
887953 |
ret = glusterd_get_value_for_vme_entry
|
|
|
887953 |
(vme, &def_val);
|
|
|
887953 |
+ get_value_vme = _gf_true;
|
|
|
887953 |
if (!all_opts && ret)
|
|
|
887953 |
goto out;
|
|
|
887953 |
else if (ret == -2)
|
|
|
887953 |
@@ -13179,6 +13182,8 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
|
|
|
887953 |
GD_MSG_DICT_SET_FAILED,
|
|
|
887953 |
"Failed to "
|
|
|
887953 |
"set %s in dictionary", vme->key);
|
|
|
887953 |
+ if (get_value_vme)
|
|
|
887953 |
+ GF_FREE (def_val);
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
sprintf (dict_key, "value%d", count);
|
|
|
887953 |
@@ -13189,8 +13194,14 @@ glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
|
|
|
887953 |
"Failed to "
|
|
|
887953 |
"set %s for key %s in dictionary", def_val,
|
|
|
887953 |
vme->key);
|
|
|
887953 |
+ if (get_value_vme)
|
|
|
887953 |
+ GF_FREE (def_val);
|
|
|
887953 |
+
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
+ if (get_value_vme)
|
|
|
887953 |
+ GF_FREE (def_val);
|
|
|
887953 |
+
|
|
|
887953 |
def_val = NULL;
|
|
|
887953 |
if (!all_opts)
|
|
|
887953 |
break;
|
|
|
887953 |
--
|
|
|
887953 |
2.20.1
|
|
|
887953 |
|