cead9d
From 0d8c6d78130d22c475010bcce8055073b19de82a Mon Sep 17 00:00:00 2001
cead9d
From: Xie Changlong <xiechanglong@cmss.chinamobile.com>
cead9d
Date: Fri, 17 May 2019 18:33:11 +0800
cead9d
Subject: [PATCH 358/362] inode: fix wrong loop count in __inode_ctx_free
cead9d
cead9d
Avoid serious memory leak
cead9d
cead9d
Backport of :
cead9d
>fixes: bz#1711240
cead9d
>Upstream patch link: https://review.gluster.org/#/c/glusterfs/+/22738/
cead9d
>Change-Id: Ic61a8fdd0e941e136c98376a87b5a77fa8c22316
cead9d
>Signed-off-by: Xie Changlong <xiechanglong@cmss.chinamobile.com>
cead9d
cead9d
BUG: 1781543
cead9d
Change-Id: I601ebb6cd6744a61c64edd3d21d3b9a0edf1e95b
cead9d
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
cead9d
Reviewed-on: https://code.engineering.redhat.com/gerrit/195611
cead9d
Tested-by: RHGS Build Bot <nigelb@redhat.com>
cead9d
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
cead9d
---
cead9d
 libglusterfs/src/inode.c | 11 ++++++-----
cead9d
 1 file changed, 6 insertions(+), 5 deletions(-)
cead9d
cead9d
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
cead9d
index 5331e93..9dbb25b 100644
cead9d
--- a/libglusterfs/src/inode.c
cead9d
+++ b/libglusterfs/src/inode.c
cead9d
@@ -402,14 +402,15 @@ __inode_ctx_free(inode_t *inode)
cead9d
         goto noctx;
cead9d
     }
cead9d
 
cead9d
-    for (index = 0; index < inode->table->xl->graph->xl_count; index++) {
cead9d
+    for (index = 0; index < inode->table->ctxcount; index++) {
cead9d
         if (inode->_ctx[index].value1 || inode->_ctx[index].value2) {
cead9d
             xl = (xlator_t *)(long)inode->_ctx[index].xl_key;
cead9d
-            old_THIS = THIS;
cead9d
-            THIS = xl;
cead9d
-            if (!xl->call_cleanup && xl->cbks->forget)
cead9d
+            if (xl && !xl->call_cleanup && xl->cbks->forget) {
cead9d
+                old_THIS = THIS;
cead9d
+                THIS = xl;
cead9d
                 xl->cbks->forget(xl, inode);
cead9d
-            THIS = old_THIS;
cead9d
+                THIS = old_THIS;
cead9d
+            }
cead9d
         }
cead9d
     }
cead9d
 
cead9d
-- 
cead9d
1.8.3.1
cead9d