Skip to content

Commit 684826f

Browse files
sergey-senozhatskyakpm00
authored andcommitted
zram: free secondary algorithms names
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>
1 parent 2abbcc0 commit 684826f

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
@@ -2112,6 +2112,11 @@ static void zram_destroy_comps(struct zram *zram)
21122112
zram->num_active_comps--;
21132113
}
21142114

2115+
for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
2116+
kfree(zram->comp_algs[prio]);
2117+
zram->comp_algs[prio] = NULL;
2118+
}
2119+
21152120
zram_comp_params_reset(zram);
21162121
}
21172122

0 commit comments

Comments
 (0)