public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zram: free secondary algorithms names
@ 2024-09-11  2:54 Sergey Senozhatsky
  2024-09-16 14:44 ` Andrew Morton
  2024-09-17  1:30 ` [PATCHv2] " Sergey Senozhatsky
  0 siblings, 2 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2024-09-11  2:54 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Minchan Kim, linux-kernel, Sergey Senozhatsky

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 | 7 +++++++
 1 file changed, 7 insertions(+)

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-24 18:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  2:54 [PATCH] zram: free secondary algorithms names Sergey Senozhatsky
2024-09-16 14:44 ` Andrew Morton
2024-09-17  1:29   ` Sergey Senozhatsky
2024-09-17  1:30 ` [PATCHv2] " Sergey Senozhatsky
     [not found]   ` <CAF8kJuPq+JwvwrG+H+XU23Xz+Do+qy8RPJBBVRsL0YGQzZpfrQ@mail.gmail.com>
2024-09-24 15:52     ` Chris Li
2024-09-24 18:05       ` Chris Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox