[PATCH 1/8] nvmem: core: make reg_write() take a const void *

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Jul 15 11:00:56 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Modifying the `nvmem_reg_write_t` callback signature to use `const void *val` without updating the implementing drivers causes widespread build failures and runtime kCFI panics.
--

--- Patch [1]: [PATCH 1/8] nvmem: core: make reg_write() take a const void * ---
commit 465aa1ef7ad6475c286716a1fffc7cdb9b6f09dc
Author: Link Mauve <linkmauve at linkmauve.fr>

nvmem: core: make reg_write() take a const void *

This commit changes the nvmem_reg_write_t callback signature to expect
a const void * instead of a mutable void *.

> diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
> index f3b13da78aac9..e62285836cbbe 100644
> --- a/include/linux/nvmem-provider.h
> +++ b/include/linux/nvmem-provider.h
> @@ -19,7 +19,7 @@ struct nvmem_device;
>  typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
>  				void *val, size_t bytes);
>  typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
> -				 void *val, size_t bytes);
> +				 const void *val, size_t bytes);

[Severity: High]
Does modifying this callback signature without updating the implementing
drivers cause widespread build failures and runtime kCFI panics?

For example, drivers/nvmem/bcm-ocotp.c:bcm_otpc_write() still expects
a mutable void *:

static int bcm_otpc_write(void *context, unsigned int offset, void *val,
                          size_t bytes)

When this is assigned to reg_write in bcm_otpc_nvmem_config, it causes an
incompatible pointer type mismatch. This leads to build errors with modern
compilers or -Werror, and will trigger kernel panics upon any nvmem write
operation on kernels with Control-Flow Integrity (kCFI) enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715175229.24672-1-linkmauve@linkmauve.fr?part=1



More information about the linux-amlogic mailing list