From 1ebd2a3227469b1775f19c8f78af7d3d19f749a3 Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Fri, 26 Apr 2019 08:47:12 +0530
Subject: [PATCH 399/449] glusterd: coverity fixes
1400775 - USE_AFTER_FREE
1400742 - Missing Unlock
1400736 - CHECKED_RETURN
1398470 - Missing Unlock
Missing unlock is the tricky one, we have had annotation added, but
coverity still continued to complaint. Added pthread_mutex_unlock to
clean up the lock before destroying it to see if it makes coverity
happy.
> upstream patch link: https://review.gluster.org/#/c/glusterfs/+/22634/
> Updates: bz#789278
> Change-Id: I1d892612a17f805144d96c1b15004a85a1639414
> Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
BUG: 1787310
Change-Id: I1d892612a17f805144d96c1b15004a85a1639414
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/202343
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
xlators/mgmt/glusterd/src/glusterd-peer-utils.c | 1 +
xlators/mgmt/glusterd/src/glusterd-sm.c | 1 -
xlators/mgmt/glusterd/src/glusterd-utils.c | 8 +++++++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
index f24c86e..8c1feeb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
@@ -48,6 +48,7 @@ glusterd_peerinfo_destroy(struct rcu_head *head)
}
glusterd_sm_tr_log_delete(&peerinfo->sm_log);
+ pthread_mutex_unlock(&peerinfo->delete_lock);
pthread_mutex_destroy(&peerinfo->delete_lock);
GF_FREE(peerinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index 54a7bd1..044da3d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -868,7 +868,6 @@ glusterd_ac_friend_remove(glusterd_friend_sm_event_t *event, void *ctx)
"Cleanup returned: %d", ret);
}
out:
- /* coverity[ LOCK] */
return 0;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 1b78812..a1299bc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -5840,7 +5840,13 @@ attach_brick_callback(struct rpc_req *req, struct iovec *iov, int count,
/* PID file is copied once brick has attached
successfully
*/
- glusterd_copy_file(pidfile1, pidfile2);
+ ret = glusterd_copy_file(pidfile1, pidfile2);
+ if (ret) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, GD_MSG_NO_MEMORY,
+ "Could not copy file %s to %s", pidfile1, pidfile2);
+ goto out;
+ }
+
brickinfo->status = GF_BRICK_STARTED;
brickinfo->rpc = rpc_clnt_ref(other_brick->rpc);
gf_log(THIS->name, GF_LOG_INFO, "brick %s is attached successfully",
--
1.8.3.1