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