summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLalatendu Mohanty <lmohanty@redhat.com>2014-01-02 20:04:46 +0530
committerVijay Bellur <vbellur@redhat.com>2014-01-04 04:55:32 -0800
commit0fbb9c7baf13331d72fc42243cd031c2d7acdbe7 (patch)
treeb685893e6f2fe633a678da58cd598297ebcb4d98
parent79cbf27b9b98d1feebcc2f1db5fc1c976d2c24cf (diff)
Crypt: Fixing incorrect placement of GF_FREE
i.e. we are trying access the memory after freeing it using GF_FREE Change-Id: I2b22fd421131c618bd0d7c246ebf09f14751ad30 Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com> Reviewed-on: http://review.gluster.org/6626 Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/encryption/crypt/src/crypt.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/xlators/encryption/crypt/src/crypt.c b/xlators/encryption/crypt/src/crypt.c
index 47ff38e501d..becff3e4763 100644
--- a/xlators/encryption/crypt/src/crypt.c
+++ b/xlators/encryption/crypt/src/crypt.c
@@ -3277,15 +3277,15 @@ static int32_t linkop_grab_local(call_frame_t *frame,
if (newloc) {
local->newloc = GF_CALLOC(1, sizeof(*newloc), gf_crypt_mt_loc);
if (!local->newloc) {
- GF_FREE(local->loc);
loc_wipe(local->loc);
+ GF_FREE(local->loc);
goto error;
}
memset(local->newloc, 0, sizeof(*local->newloc));
ret = loc_copy(local->newloc, newloc);
if (ret) {
- GF_FREE(local->loc);
loc_wipe(local->loc);
+ GF_FREE(local->loc);
GF_FREE(local->newloc);
goto error;
}
@@ -3297,19 +3297,21 @@ static int32_t linkop_grab_local(call_frame_t *frame,
goto error;
}
return 0;
- error:
- if (local->xdata)
- dict_unref(local->xdata);
- if (local->fd)
- fd_unref(local->fd);
- local->fd = 0;
- local->loc = NULL;
- local->newloc = NULL;
- local->op_ret = -1;
- local->op_errno = ret;
+error:
+ if (local) {
+ if (local->xdata)
+ dict_unref(local->xdata);
+ if (local->fd)
+ fd_unref(local->fd);
+ local->fd = 0;
+ local->loc = NULL;
+ local->newloc = NULL;
+ local->op_ret = -1;
+ local->op_errno = ret;
+ }
- return ret;
+ return ret;
}
/*