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