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