Skip to content

Commit 6272936

Browse files
sergey-senozhatskygregkh
authored andcommitted
zram: free secondary algorithms names
[ Upstream commit 684826f ] We need to kfree() secondary algorithms names when reset zram device that had multi-streams, otherwise we leak memory. [senozhatsky@chromium.org: kfree(NULL) is legal] Link: https://lkml.kernel.org/r/20240917013021.868769-1-senozhatsky@chromium.org Link: https://lkml.kernel.org/r/20240911025600.3681789-1-senozhatsky@chromium.org Fixes: 001d927 ("zram: add recompression algorithm sysfs knob") Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Minchan Kim <minchan@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c556e72 commit 6272936

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/block/zram/zram_drv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,11 @@ static void zram_destroy_comps(struct zram *zram)
19831983
zcomp_destroy(comp);
19841984
zram->num_active_comps--;
19851985
}
1986+
1987+
for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
1988+
kfree(zram->comp_algs[prio]);
1989+
zram->comp_algs[prio] = NULL;
1990+
}
19861991
}
19871992

19881993
static void zram_reset_device(struct zram *zram)

0 commit comments

Comments
 (0)