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