[PATCH v5 0/4] zram: fix zstd error paths and add parameter validation

From: Haoqin Huang

Date: Mon Aug 03 2026 - 11:48:39 EST


From: Haoqin Huang <haoqinhuang@xxxxxxxxxxx>

Patch 1 removes zstd_release_params() from both zstd_create() and
zstd_setup_params() error paths, the former is a layering violation
in a per-CPU callback, the latter is redundant as zcomp_init() already
calls release_params() on setup failure.

Patch 2 rejects zero-size dictionaries and prints an error on dict
load failure (currently errors are silently swallowed).

Patch 3 validates dict and level parameters in each backend's
.setup_params(), rejecting unsupported combinations and out-of-range
levels.

Patch 4 resets per-priority params on algorithm change before init.

Changes since v4:
- Patch 1: merged zstd_setup_params() zstd_release_params() removal;
reworded commit message
- Patch 2: removed "zram:" prefix from pr_err (pr_fmt already adds
it); reworded commit message
- Patch 3: dropped lz4 U16_MAX upper bound (the library has no
limit); changed lz4hc lower bound from LZ4HC_MIN_CLEVEL to < 1
(the library supports levels 1-2); rebased on tree with deflate
winbits validation
- Patch 4: moved comp_params_reset() up instead of using a forward
declaration

v4: https://lore.kernel.org/all/20260730060133.80233-1-haoqinhuang7@xxxxxxxxx/

Haoqin Huang (4):
zram: do not release zstd global params from error paths
zram: reject zero-size dictionary
zram: validate parameters in each backend's setup_params
zram: reset per-priority params when changing algorithm before init

drivers/block/zram/backend_842.c | 8 ++++++++
drivers/block/zram/backend_deflate.c | 11 +++++++++++
drivers/block/zram/backend_lz4.c | 4 ++++
drivers/block/zram/backend_lz4hc.c | 4 ++++
drivers/block/zram/backend_lzo.c | 8 ++++++++
drivers/block/zram/backend_lzorle.c | 8 ++++++++
drivers/block/zram/backend_zstd.c | 7 +++++--
drivers/block/zram/zram_drv.c | 29 ++++++++++++++++------------
8 files changed, 65 insertions(+), 14 deletions(-)

--
2.43.7