[PATCH 1/1] z3fold: fix memory leak

From: Xidong Wang
Date: Tue Apr 03 2018 - 20:52:33 EST


In function z3fold_create_pool(), the memory allocated by
__alloc_percpu() is not released on the error path that pool->compact_wq
, which holds the return value of create_singlethread_workqueue(), is NULL.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang <wangxidong_97@xxxxxxx>
---
mm/z3fold.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/mm/z3fold.c b/mm/z3fold.c
index d589d31..b987cc5 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -490,6 +490,7 @@ static struct z3fold_pool *z3fold_create_pool(const char *name, gfp_t gfp,
out_wq:
destroy_workqueue(pool->compact_wq);
out:
+ free_percpu(pool->unbuddied);
kfree(pool);
return NULL;
}
--
2.7.4