Skip to contentSkip to conversation

mm/zswap: bugfix: memory leak when re-swapon

PATCH In review Weijie Yang 2 participants 2 messages Sep 23, 2013 – Sep 24, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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().

---
 mm/zswap.c |    4 ++++
 1 file changed, 4 insertions(+)
mm/zswap.c +4 -0
index deda2b6..cbd9578 100644
@@ -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 = {
Signature · 1 line
1.7.10.4
Reviewed-by on v3 1/3
#1 lore raw
Quoted 10 lines · Weijie Yang

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().

Signature · 8 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>