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