[PATCH v6 1/5] zram: do not release zstd global params from error paths

Haoqin Huang <[email protected]>
Newsgroups gmane.linux.block,gmane.linux.kernel
Message-ID <[email protected]>
From: Haoqin Huang <[email protected]>

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. This is a layering violation: a
per-CPU callback should only clean up its own context, not release
resources owned by the compression lifecycle.

zstd_setup_params() called zstd_release_params() on its own error
path as well, but zcomp_init() already calls release_params() when
setup fails, so this is redundant.

Remove zstd_release_params() from both error paths.

Signed-off-by: Haoqin Huang <[email protected]>
Signed-off-by: Rongwei Wang <[email protected]>
---
 drivers/block/zram/backend_zstd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/block/zram/backend_zstd.c b/drivers/block/zram/backend_zstd.c
index d00b548056dc..5fabc3e7e975 100644
--- a/drivers/block/zram/backend_zstd.c
+++ b/drivers/block/zram/backend_zstd.c
@@ -85,7 +85,6 @@ static int zstd_setup_params(struct zcomp_params *params)
 	return 0;
 
 error:
-	zstd_release_params(params);
 	return -EINVAL;
 }
 
@@ -161,7 +160,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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.