diff options
author | Krishnan Parthasarathi <kp@gluster.com> | 2011-06-10 04:42:28 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-06-10 03:53:58 -0700 |
commit | 25da481bc5b06d671e41e5a70b2c145777154bf1 (patch) | |
tree | c58240c266f711778181d96e270f9ea6a053e145 /xlators/cluster/afr/src/afr-self-heal-data.c | |
parent | fb42a67e1eea17b3dc116d26ea92b93f740b28c3 (diff) |
pump: cleanup potential dict related memory corruption.v3.1.5qa2
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2489 (GlusterFS crashing with replace-brick)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2489
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 5adaba1c974..d4516c4ce1e 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -859,12 +859,11 @@ afr_sh_data_fxattrop_cbk (call_frame_t *frame, void *cookie, int afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this) { - afr_self_heal_t *sh = NULL; - afr_local_t *local = NULL; - afr_private_t *priv = NULL; - dict_t *xattr_req = NULL; - - int32_t zero_pending[3] = {0, 0, 0}; + afr_self_heal_t *sh = NULL; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + dict_t *xattr_req = NULL; + int32_t *zero_pending = NULL; int call_count = 0; int i = 0; @@ -880,14 +879,21 @@ afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this) local->call_count = call_count; xattr_req = dict_new(); - if (xattr_req) { - for (i = 0; i < priv->child_count; i++) { - ret = dict_set_static_bin (xattr_req, priv->pending_key[i], - zero_pending, 3 * sizeof(int32_t)); - if (ret < 0) - gf_log (this->name, GF_LOG_WARNING, - "Unable to set dict value"); + if (!xattr_req) { + ret = -1; + goto out; + } + for (i = 0; i < priv->child_count; i++) { + zero_pending = GF_CALLOC (3, sizeof (int32_t), gf_common_mt_int32_t); + if (!zero_pending) { + ret = -1; + goto out; } + ret = dict_set_dynptr (xattr_req, priv->pending_key[i], + zero_pending, 3 * sizeof(int32_t)); + if (ret < 0) + gf_log (this->name, GF_LOG_WARNING, + "Unable to set dict value"); } for (i = 0; i < priv->child_count; i++) { @@ -904,8 +910,14 @@ afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this) } } +out: if (xattr_req) dict_unref (xattr_req); + if (ret) { + GF_FREE (zero_pending) + sh->op_failed = -1; + afr_sh_data_done (frame, this); + } return 0; } |