Linux MM tree latest commits
 help / color / mirror / Atom feed
* + zram-validate-level-before-allocation-in-zstd_setup_params.patch added to mm-new branch
       [not found] <20261201090703.1040645-3-senozhatsky@chromium.org>
@ 2026-12-01 20:45 ` Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-12-01 20:45 UTC (permalink / raw)
  To: mm-commits, richardycc, minchan, senozhatsky, akpm


The patch titled
     Subject: zram: validate level before allocation in zstd_setup_params()
has been added to the -mm mm-new branch.  Its filename is
     zram-validate-level-before-allocation-in-zstd_setup_params.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/zram-validate-level-before-allocation-in-zstd_setup_params.patch

This patch will later appear in the mm-new branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews.  Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: zram: validate level before allocation in zstd_setup_params()
Date: Tue, 01 Dec 2026 18:06:35 +0900

zstd_setup_params() currently allocates ->drv_data before checking
params->level.  Validate params->level before allocating zstd_params and
compute zstd_get_cparams() only when a dictionary is present, so that we
can drop the error label.

Link: https://patch.msgid.link/20261201090703.1040645-3-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Richard Chang <richardycc@google.com>

 drivers/block/zram/backend_zstd.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

--- a/drivers/block/zram/backend_zstd.c~zram-validate-level-before-allocation-in-zstd_setup_params
+++ a/drivers/block/zram/backend_zstd.c
@@ -60,47 +60,43 @@ static int zstd_setup_params(struct zcom
 	zstd_compression_parameters prm;
 	struct zstd_params *zp;
 
-	zp = kzalloc_obj(*zp);
-	if (!zp)
-		return -ENOMEM;
-
-	params->drv_data = zp;
 	if (params->level == ZCOMP_PARAM_NOT_SET) {
 		params->level = zstd_default_clevel();
 	} else if (params->level < zstd_min_clevel() ||
 		   params->level > zstd_max_clevel()) {
 		pr_err("invalid compression level %d\n", params->level);
-		goto error;
+		return -EINVAL;
 	}
 
+	zp = kzalloc_obj(*zp);
+	if (!zp)
+		return -ENOMEM;
+
+	params->drv_data = zp;
 	zp->cprm = zstd_get_params(params->level, PAGE_SIZE);
 
 	zp->custom_mem.customAlloc = zstd_custom_alloc;
 	zp->custom_mem.customFree = zstd_custom_free;
 
-	prm = zstd_get_cparams(params->level, PAGE_SIZE,
-			       params->dict_sz);
-
 	if (!params->dict || !params->dict_sz)
 		return 0;
 
+	prm = zstd_get_cparams(params->level, PAGE_SIZE,
+			       params->dict_sz);
 	zp->cdict = zstd_create_cdict_byreference(params->dict,
 						  params->dict_sz,
 						  prm,
 						  zp->custom_mem);
 	if (!zp->cdict)
-		goto error;
+		return -EINVAL;
 
 	zp->ddict = zstd_create_ddict_byreference(params->dict,
 						  params->dict_sz,
 						  zp->custom_mem);
 	if (!zp->ddict)
-		goto error;
+		return -EINVAL;
 
 	return 0;
-
-error:
-	return -EINVAL;
 }
 
 static void zstd_destroy_cctx(struct zcomp_ctx *ctx)
_

Patches currently in -mm which might be from senozhatsky@chromium.org are

zram-prefix-backends-printk-s.patch
zram-remove-debugfs-entry-on-init-failure.patch
zram-reset-writeback-state-in-zram_reset_device.patch
zram-move-mark_slot_accessed-under-existing-slot-lock-sections.patch
zram-remove-stale-warn_on-from-zram_read_page.patch
zram-zstd-do-not-allocate-empty-c-d-dictionaries.patch
zram-lz4hc-pre-initialize-dictionary-stream-in-setup_params.patch
zram-lz4-use-lz4_decompress_safe_usingdict.patch
zram-lz4hc-use-lz4_decompress_safe_usingdict.patch
zram-zstd-do-not-use-kvzalloc-for-zstd-allocations.patch
zram-split-zcomp-into-separate-r-w-streams.patch
zram-introduce-shared-decompression-streams.patch
zram-allocate-bounce-buffer-for-spanning-objects.patch
zram-borrow-idle-decompression-streams-in-exclusive-mode.patch
zram-use-a-singleton-compression-context-for-recompression.patch
zram-drop-stale-comment-in-write_incompressible_page.patch
zram-drop-get_slot_handle-and-set_slot_handle.patch
zsmalloc-return-handle-from-obj_allocated.patch
zsmalloc-switch-handle-type-to-struct-zs_handle.patch
zram-check-mem_limit-before-allocating-zsmalloc-object.patch
zram-allocate-zsmalloc-object-under-slot-lock.patch
zswap-do-not-free-the-entry-if-its-pool-is-null.patch
zsmalloc-encode-1-based-obj_idx-so-valid-obj-is-never-0.patch
zsmalloc-embed-struct-zs_handle-into-zram-and-zswap-entries.patch
zsmalloc-fold-zs_obj_write-into-zs_store.patch
zsmalloc-populate-new-zspage-outside-class-lock-in-zs_store.patch
zram-fix-quadratic-writeback-bitmap-search.patch
zsmalloc-free-a-zspages-pages-in-one-batch.patch
zram-keep-the-hot-statistics-per-cpu.patch
zram-do-not-modify-cont-sysfs-store-buffers.patch
zram-avoid-rollback-uaf-in-zcomp_cpu_up_prepare.patch
zram-publish-streams-under-lock-in-zcomp_cpu_up_prepare.patch
zram-allocate-comp-only-if-it-is-supported.patch
zram-validate-level-before-allocation-in-zstd_setup_params.patch
zram-defer-wb_ctl-allocation-in-writeback_store.patch
zram-remove-out-label-in-recompress_store.patch
zram-create-debugfs-dir-after-register_blkdev-in-zram_init.patch
zram-respect-80-cols-limit-in-zram_meta_alloc.patch
zram-rename-mark_idle-to-mark_slots_idle.patch
zsmalloc-fix-spdx-license-identifier.patch
zram-use-spdx-license-identifier.patch
maintainers-add-mm-and-block-lists-to-zram-entry.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-01 20:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261201090703.1040645-3-senozhatsky@chromium.org>
2026-12-01 20:45 ` + zram-validate-level-before-allocation-in-zstd_setup_params.patch added to mm-new branch Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox