[PATCHv2] zram: free secondary algorithms names

Sergey Senozhatsky posted 1 patch 2 months, 1 week ago
drivers/block/zram/zram_drv.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCHv2] zram: free secondary algorithms names
Posted by Sergey Senozhatsky 2 months, 1 week ago
We need to kfree() secondary algorithms names when reset
zram device that had multi-streams, otherwise we leak memory.

Fixes: 001d92735701 ("zram: add recompression algorithm sysfs knob")
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 drivers/block/zram/zram_drv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f8206ba6cbbb..c3d245617083 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2115,6 +2115,11 @@ static void zram_destroy_comps(struct zram *zram)
 		zram->num_active_comps--;
 	}
 
+	for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
+		kfree(zram->comp_algs[prio]);
+		zram->comp_algs[prio] = NULL;
+	}
+
 	zram_comp_params_reset(zram);
 }
 
-- 
2.46.0.662.g92d0881bb0-goog