[PATCH] zram: do not free same element pages in zram_meta_free
From: Minchan Kim
Date: Mon Feb 06 2017 - 22:00:05 EST
zhouxianrong pointed out that we shouldn't free same element pages
in zram_meta_free. Otherwise, it will encounter oops due to invalid
handle value.
Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
---
Andrew,
Please fold it to zram-extend-zero-pages-to-same-element-pages.patch.
Thanks.
drivers/block/zram/zram_drv.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index c20b05a84f21..a25d34a8af19 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -425,8 +425,11 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize)
/* Free all pages that are still in this zram device */
for (index = 0; index < num_pages; index++) {
unsigned long handle = meta->table[index].handle;
-
- if (!handle)
+ /*
+ * No memory is allocated for same element filled pages.
+ * Simply clear same page flag.
+ */
+ if (!handle || zram_test_flag(meta, index, ZRAM_SAME))
continue;
zs_free(meta->mem_pool, handle);
--
2.7.4