From da66edbe927152ba12c9a702fd157a45a3f3cb42 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Fri, 15 Apr 2011 14:02:39 +0000 Subject: mgmt/glusterd: fix double free. - the limit-usage string should be stored as static, since remove-limits will be modifying it and probably freeing it. - this static string should also be explicitly freed in glusterd_quota_disable since dict_del won't free it. Signed-off-by: Raghavendra G Signed-off-by: Vijay Bellur BUG: 2776 (gluster quota remove crashed glusterd) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2776 --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 8f4b63096a0..fae19e2265e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -5208,7 +5208,7 @@ int32_t glusterd_quota_disable (glusterd_volinfo_t *volinfo, char **op_errstr) { int32_t ret = -1; - char *quota_status = NULL; + char *quota_status = NULL, *quota_limits = NULL; GF_VALIDATE_OR_GOTO ("glusterd", volinfo, out); GF_VALIDATE_OR_GOTO ("glusterd", op_errstr, out); @@ -5235,6 +5235,14 @@ glusterd_quota_disable (glusterd_volinfo_t *volinfo, char **op_errstr) *op_errstr = gf_strdup ("Disabling quota has been successful"); + ret = glusterd_volinfo_get (volinfo, VKEY_FEATURES_LIMIT_USAGE, + "a_limits); + if (ret) { + gf_log ("", GF_LOG_WARNING, "failed to get the quota limits"); + } else { + GF_FREE (quota_limits); + } + dict_del (volinfo->dict, VKEY_FEATURES_LIMIT_USAGE); out: @@ -5314,8 +5322,8 @@ glusterd_quota_limit_usage (glusterd_volinfo_t *volinfo, dict_t *dict, char **op quota_limits = value; - ret = dict_set_dynstr (volinfo->dict, VKEY_FEATURES_LIMIT_USAGE, - quota_limits); + ret = dict_set_str (volinfo->dict, VKEY_FEATURES_LIMIT_USAGE, + quota_limits); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to set quota limits" ); *op_errstr = gf_strdup ("failed to set limit"); -- cgit