Skip to content

Commit f58ee48

Browse files
sergey-senozhatskymehmetb0
authored andcommitted
zram: free secondary algorithms names
BugLink: https://bugs.launchpad.net/bugs/2097301 [ 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> CVE-2024-50064 Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
1 parent ac7264f commit f58ee48

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
@@ -1979,6 +1979,11 @@ static void zram_destroy_comps(struct zram *zram)
19791979
zcomp_destroy(comp);
19801980
zram->num_active_comps--;
19811981
}
1982+
1983+
for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
1984+
kfree(zram->comp_algs[prio]);
1985+
zram->comp_algs[prio] = NULL;
1986+
}
19821987
}
19831988

19841989
static void zram_reset_device(struct zram *zram)

0 commit comments

Comments
 (0)