2013-09-23 08:25:41

by Weijie Yang

[permalink] [raw]
Subject: [PATCH v3 1/3] mm/zswap: bugfix: memory leak when re-swapon

zswap_tree is not freed when swapoff, and it got re-kmalloc in swapon,
so memory-leak occurs.

Modify: free memory of zswap_tree in zswap_frontswap_invalidate_area().

Signed-off-by: Weijie Yang <[email protected]>
Reviewed-by: Bob Liu <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: [email protected]
Acked-by: Seth Jennings <[email protected]>
---
mm/zswap.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/mm/zswap.c b/mm/zswap.c
index deda2b6..cbd9578 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -816,6 +816,10 @@ static void zswap_frontswap_invalidate_area(unsigned type)
}
tree->rbroot = RB_ROOT;
spin_unlock(&tree->lock);
+
+ zbud_destroy_pool(tree->pool);
+ kfree(tree);
+ zswap_trees[type] = NULL;
}

static struct zbud_ops zswap_zbud_ops = {
--
1.7.10.4


2013-09-24 00:05:40

by Minchan Kim

[permalink] [raw]
Subject: Re: [PATCH v3 1/3] mm/zswap: bugfix: memory leak when re-swapon

On Mon, Sep 23, 2013 at 04:21:49PM +0800, Weijie Yang wrote:
> zswap_tree is not freed when swapoff, and it got re-kmalloc in swapon,
> so memory-leak occurs.
>
> Modify: free memory of zswap_tree in zswap_frontswap_invalidate_area().
>
> Signed-off-by: Weijie Yang <[email protected]>
> Reviewed-by: Bob Liu <[email protected]>
> Cc: Minchan Kim <[email protected]>
> Cc: [email protected]
> Acked-by: Seth Jennings <[email protected]>

Reviewed-by: Minchan Kim <[email protected]>

--
Kind regards,
Minchan Kim