lkml.org 
[lkml]   [2013]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 1/4] zswap bugfix: memory leaks when re-swapon
From
zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon,
memory leak occurs.
Add check statement in zswap_frontswap_init so that zswap_tree is
inited only once.

---
mm/zswap.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index deda2b6..1cf1c07 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -826,6 +826,11 @@ static void zswap_frontswap_init(unsigned type)
{
struct zswap_tree *tree;

+ if (zswap_trees[type]) {
+ BUG_ON(zswap_trees[type]->rbroot != RB_ROOT); /* invalidate_area set it */
+ return;
+ }
+
tree = kzalloc(sizeof(struct zswap_tree), GFP_KERNEL);
if (!tree)
goto err;
--
1.7.0.4

\
 
 \ /
  Last update: 2013-08-23 13:21    [W:0.088 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site