summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanju Rakonde <srakonde@redhat.com>2018-09-20 11:37:36 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-09-22 13:29:33 +0000
commit27402fcb27a7e9ea32a6a04fdc21b59af6320bb4 (patch)
tree29d68a69e31063d2225af171b17c38bcee8935a5
parentf72f18b3bf7f9535827a059a5090476b3141723f (diff)
downloadglusterfs-27402fcb27a7e9ea32a6a04fdc21b59af6320bb4.tar.gz
glusterfs-27402fcb27a7e9ea32a6a04fdc21b59af6320bb4.tar.xz
glusterfs-27402fcb27a7e9ea32a6a04fdc21b59af6320bb4.zip
glusterd: fix coverity issues in glusterd-locks.c
This patch addresses CID 1395254, CID 1382436. We are allocating memory to mgmt_lock_timer and key_dup. while doing GF_VALIDATE_OR_GOTO for mgmt_lock_timer_xl or mgmt_lock_timer_ctx, if it is null going to out without freeing the memory. This patch will fix the issues. updates: bz#789278 Change-Id: Ic6bfb2052982b16373f90cbbc53d2b2da052c01f Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-locks.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c
index 84e9ca1826..981d6c4442 100644
--- a/xlators/mgmt/glusterd/src/glusterd-locks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-locks.c
@@ -624,10 +624,18 @@ glusterd_mgmt_v3_lock(const char *name, uuid_t uuid, uint32_t *op_errno,
ret = -1;
mgmt_lock_timer_xl = mgmt_lock_timer->xl;
- GF_VALIDATE_OR_GOTO(this->name, mgmt_lock_timer_xl, out);
+ if (!mgmt_lock_timer_xl) {
+ GF_FREE(mgmt_lock_timer);
+ GF_FREE(key_dup);
+ goto out;
+ }
mgmt_lock_timer_ctx = mgmt_lock_timer_xl->ctx;
- GF_VALIDATE_OR_GOTO(this->name, mgmt_lock_timer_ctx, out);
+ if (!mgmt_lock_timer_ctx) {
+ GF_FREE(mgmt_lock_timer);
+ GF_FREE(key_dup);
+ goto out;
+ }
mgmt_lock_timer->timer = gf_timer_call_after(
mgmt_lock_timer_ctx, delay, gd_mgmt_v3_unlock_timer_cbk, key_dup);
@@ -637,6 +645,7 @@ glusterd_mgmt_v3_lock(const char *name, uuid_t uuid, uint32_t *op_errno,
if (ret) {
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
"Unable to set timer in mgmt_v3 lock");
+ GF_FREE(key_dup);
GF_FREE(mgmt_lock_timer);
goto out;
}