DORMANTno replies

[PATCH] mm/zswap: fix potential memory leak

From: Tian Tao <tiantao6@hisilicon.com>
Date: 2021-01-25 01:33:16
Subsystem: memory management, the rest, zswap compressed swap caching · Maintainers: Andrew Morton, Linus Torvalds, Johannes Weiner, Yosry Ahmed, Nhat Pham

If entry is NULL, the requested memory tmp should be freed,
otherwise it may cause a memory leak.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Reported-by: Dan Carpenter <redacted>
---
 mm/zswap.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/mm/zswap.c b/mm/zswap.c
index 42d13dd..8d1381b 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -961,6 +961,7 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
 		/* entry was invalidated */
 		spin_unlock(&tree->lock);
 		zpool_unmap_handle(pool, handle);
+		kfree(tmp);
 		return 0;
 	}
 	spin_unlock(&tree->lock);
-- 
2.7.4

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help