[PATCH v2 1/5] zram: fix early release of global cdict/ddict in per-CPU error path

From: Haoqin Huang

Date: Tue Jul 28 2026 - 05:40:44 EST


From: Haoqin Huang <haoqinhuang@xxxxxxxxxxx>

zstd_setup_params() creates global cdict and ddict stored in
params->drv_data, shared across all per-CPU contexts. The per-CPU
zstd_create() error path called zstd_release_params(), which freed
those globally-shared objects. While the drv_data=NULL guard in
zstd_release_params() prevents a double-free on the init failure
path, this is still a layering violation: a per-CPU callback should
only clean up its own context, not release resources owned by the
compression lifecycle (zcomp_init / zcomp_destroy).

Fix by removing zstd_release_params() from the per-CPU error path
and replacing it with only zstd_destroy(), which properly cleans
up the per-CPU context without touching the global params->drv_data.

Fixes: 6a559ecd6e7e ("zram: add dictionary support to zstd backend")
Signed-off-by: Haoqin Huang <haoqinhuang@xxxxxxxxxxx>
Signed-off-by: Rongwei Wang <zigiwang@xxxxxxxxxxx>
---
drivers/block/zram/backend_zstd.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/block/zram/backend_zstd.c b/drivers/block/zram/backend_zstd.c
index d00b548056dc..2584f47c9b3c 100644
--- a/drivers/block/zram/backend_zstd.c
+++ b/drivers/block/zram/backend_zstd.c
@@ -161,7 +161,6 @@ static int zstd_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
return 0;

error:
- zstd_release_params(params);
zstd_destroy(ctx);
return -EINVAL;
}
--
2.43.7