14f8ab
From b3647eb5415b2e3d9e1a11ad6c4689e520f17b39 Mon Sep 17 00:00:00 2001
14f8ab
From: mohit84 <moagrawa@redhat.com>
14f8ab
Date: Mon, 22 Feb 2021 10:09:34 +0530
14f8ab
Subject: [PATCH 534/538] glusterd: Resolve use after free bug (#2181)
14f8ab
14f8ab
In the commit 61ae58e67567ea4de8f8efc6b70a9b1f8e0f1bea
14f8ab
introduced a coverity bug use object after cleanup
14f8ab
the object.
14f8ab
14f8ab
Cleanup memory after comeout from a critical section
14f8ab
>Fixes: #2180
14f8ab
14f8ab
>Change-Id: Iee2050c4883a0dd44b8523bb822b664462ab6041
14f8ab
>Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
14f8ab
Upstream Patch : https://github.com/gluster/glusterfs/pull/2181
14f8ab
14f8ab
BUG: 1832306
14f8ab
Change-Id: Iee2050c4883a0dd44b8523bb822b664462ab6041
14f8ab
Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/228578
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-utils.c | 5 ++---
14f8ab
 1 file changed, 2 insertions(+), 3 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
14f8ab
index 9fb8eab..6d40be5 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
14f8ab
@@ -122,11 +122,10 @@ glusterd_defrag_unref(glusterd_defrag_info_t *defrag)
14f8ab
     LOCK(&defrag->lock);
14f8ab
     {
14f8ab
         refcnt = --defrag->refcnt;
14f8ab
-        if (refcnt <= 0)
14f8ab
-            GF_FREE(defrag);
14f8ab
     }
14f8ab
     UNLOCK(&defrag->lock);
14f8ab
-
14f8ab
+    if (refcnt <= 0)
14f8ab
+        GF_FREE(defrag);
14f8ab
 out:
14f8ab
     return refcnt;
14f8ab
 }
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab