From 27402fcb27a7e9ea32a6a04fdc21b59af6320bb4 Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Thu, 20 Sep 2018 11:37:36 +0530 Subject: 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 --- xlators/mgmt/glusterd/src/glusterd-locks.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c index 84e9ca18261..981d6c4442d 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; } -- cgit