summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXie Changlong <xiechanglong@cmss.chinamobile.com>2019-05-17 18:33:11 +0800
committerhari gowtham <hari.gowtham005@gmail.com>2019-12-06 10:32:29 +0000
commit4ccea5328016aaa420b0ffc43d2a2fbe9f7c8973 (patch)
treead35124e8a3ca56537dfce41ff29af590ece7405
parentf0f042780e5e8796a6a8e8fd9935fdc7bd974527 (diff)
inode: fix wrong loop count in __inode_ctx_free
Avoid serious memory leak fixes: bz#1779284 Change-Id: Ic61a8fdd0e941e136c98376a87b5a77fa8c22316 Signed-off-by: Xie Changlong <xiechanglong@cmss.chinamobile.com> (cherry picked from commit 93156e203c2f51d8a4047889a4c769564b8107b1)
-rw-r--r--libglusterfs/src/inode.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 12a8fbd014d..17959d468d9 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -402,14 +402,15 @@ __inode_ctx_free(inode_t *inode)
goto noctx;
}
- for (index = 0; index < inode->table->xl->graph->xl_count; index++) {
+ for (index = 0; index < inode->table->ctxcount; index++) {
if (inode->_ctx[index].value1 || inode->_ctx[index].value2) {
xl = (xlator_t *)(long)inode->_ctx[index].xl_key;
- old_THIS = THIS;
- THIS = xl;
- if (!xl->call_cleanup && xl->cbks->forget)
+ if (xl && !xl->call_cleanup && xl->cbks->forget) {
+ old_THIS = THIS;
+ THIS = xl;
xl->cbks->forget(xl, inode);
- THIS = old_THIS;
+ THIS = old_THIS;
+ }
}
}