]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
zram: use statically allocated compression algorithm names
authorgao xu <gaoxu2@honor.com>
Thu, 26 Feb 2026 12:37:22 +0000 (12:37 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:07 +0000 (13:53 -0700)
commitc09fb53d293a05adf1b53c800273273e59413f39
tree4bfcdd72992903c620ae1b6490390883a065bbac
parent511f04aac469a3ae04f7f2588101020aebb19c90
zram: use statically allocated compression algorithm names

Currently, zram dynamically allocates memory for compressor algorithm
names when they are set by the user.  This requires careful memory
management, including explicit `kfree` calls and special handling to avoid
freeing statically defined default compressor names.

This patch refactors the way zram handles compression algorithm names.
Instead of storing dynamically allocated copies, `zram->comp_algs` will
now store pointers directly to the static name strings defined within the
`zcomp_ops` backend structures, thereby removing the need for conditional
`kfree` calls.

Link: https://lkml.kernel.org/r/5bb2e9318d124dbcb2b743dcdce6a950@honor.com
Signed-off-by: gao xu <gaoxu2@honor.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zcomp.c
drivers/block/zram/zcomp.h
drivers/block/zram/zram_drv.c