| Message ID | 20260715175229.24672-2-linkmauve@linkmauve.fr (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-24443-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 413BD1C2FCB for <noreply@patchwork.local>; Wed, 15 Jul 2026 19:53:02 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-24443-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-24443-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 404553010622 for <noreply@patchwork.local>; Wed, 15 Jul 2026 17:53:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AD494A3402; Wed, 15 Jul 2026 17:53:00 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from luna.linkmauve.fr (82-65-109-163.subs.proxad.net [82.65.109.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCDA14A2E01; Wed, 15 Jul 2026 17:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.65.109.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784137980; cv=none; b=P9sL+xZndEoo5Por/5G6uh7Ug6Tvw5TdixiDKaU5gbyEbYV5YbA9imx1gn78ksGiTRKWxMW26X2G/fQ90I2BjF+0xaQK6h/E9zmQp6U7ObAQ+xNsNzAUmdWhb5KVheVVi5xHOLyCbGShsecLmisttSDCFG6D0/nNMREXvUcjWNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784137980; c=relaxed/simple; bh=7FuVrxLlVZ79zrxiJeyoTlMtEeJsoZeEAs4xb+NIL9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+LxxhnHOODBNmk2ryKIDmZLt3IUhZcWc+fj2Nwk327Y2GxdxbaP9kO/rM4rqmC7FVZqQelS95/ffJaq+GLlfRjqLvLBngdkAQXdDlE9S2pJg5/+X08/sutJ9zu8T8jxvwhRFgGUOiwbfUNEc21fQ3+/L8PkGN6uzr/DJf02Qso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linkmauve.fr; spf=pass smtp.mailfrom=linkmauve.fr; arc=none smtp.client-ip=82.65.109.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linkmauve.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linkmauve.fr Received: by luna.linkmauve.fr (Postfix, from userid 1000) id 989A4F40ABC; Wed, 15 Jul 2026 19:52:35 +0200 (CEST) From: Link Mauve <linkmauve@linkmauve.fr> To: Srinivas Kandagatla <srini@kernel.org> Cc: Link Mauve <linkmauve@linkmauve.fr>, Neil Armstrong <neil.armstrong@linaro.org>, Kevin Hilman <khilman@baylibre.com>, Jerome Brunet <jbrunet@baylibre.com>, Martin Blumenstingl <martin.blumenstingl@googlemail.com>, Jonathan Cameron <jic23@kernel.org>, David Lechner <dlechner@baylibre.com>, =?utf-8?q?Nuno_S=C3=A1?= <nuno.sa@analog.com>, Andy Shevchenko <andy@kernel.org>, Sakari Ailus <sakari.ailus@linux.intel.com>, Tianshu Qiu <tian.shu.qiu@intel.com>, Bingbu Cao <bingbu.cao@intel.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Aaro Koskinen <aaro.koskinen@iki.fi>, Andreas Kemnade <andreas@kemnade.info>, Roger Quadros <rogerq@kernel.org>, Tony Lindgren <tony@atomide.com>, Lee Jones <lee@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Bartosz Golaszewski <brgl@kernel.org>, "Vaibhaav Ram T.L" <vaibhaavram.tl@microchip.com>, Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>, Frank Li <Frank.Li@nxp.com>, Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix Kernel Team <kernel@pengutronix.de>, Fabio Estevam <festevam@gmail.com>, Vladimir Zapolskiy <vz@mleia.com>, =?utf-8?q?Andr=C3=A9_Draszik?= <andre.draszik@linaro.org>, Orson Zhai <orsonzhai@gmail.com>, Baolin Wang <baolin.wang@linux.alibaba.com>, Chunyan Zhang <zhang.lyra@gmail.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Praveen Teja Kundanala <praveen.teja.kundanala@amd.com>, Kalyani Akula <kalyani.akula@amd.com>, Michal Simek <michal.simek@amd.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Joshua Kinard <linux@kumba.dev>, Antoniu Miclaus <antoniu.miclaus@analog.com>, Chen-Yu Tsai <wens@kernel.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Miguel Ojeda <ojeda@kernel.org>, Boqun Feng <boqun@kernel.org>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj?= =?utf-8?q?=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Benno Lossin <lossin@kernel.org>, Andreas Hindborg <a.hindborg@kernel.org>, Alice Ryhl <aliceryhl@google.com>, Trevor Gross <tmgross@umich.edu>, Danilo Krummrich <dakr@kernel.org>, Daniel Almeida <daniel.almeida@collabora.com>, Tamir Duberstein <tamird@kernel.org>, Alexandre Courbot <acourbot@nvidia.com>, =?utf-8?q?Onur_=C3=96zkan?= <work@onurozkan.dev>, Daniel Lezcano <daniel.lezcano@kernel.org>, Johan Hovold <johan@kernel.org>, Ronald Claveau <linux-kernel-dev@aliel.fr>, Salah Triki <salah.triki@gmail.com>, Yury Norov <ynorov@nvidia.com>, David Carlier <devnexen@gmail.com>, Achim Gratz <Achim.Gratz@Stromeko.DE>, Alexander Sverdlin <alexander.sverdlin@siemens.com>, Patrick Wicki <patrick.wicki@siemens.com>, Markus Heidelberg <m.heidelberg@cab.de>, Markus Perkins <markus@notsyncing.net>, =?utf-8?q?Uwe_Kleine-K=C3=B6nig_=28?= =?utf-8?q?The_Capable_Hub=29?= <u.kleine-koenig@baylibre.com>, Bjorn Helgaas <bhelgaas@google.com>, Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>, Chen Ni <nichen@iscas.ac.cn>, Kees Cook <kees@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-media@vger.kernel.org, linux-omap@vger.kernel.org, mfd@lists.linux.dev, linux-i2c@vger.kernel.org, linux-gpio@vger.kernel.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-rtc@vger.kernel.org, linux-sunxi@lists.linux.dev, rust-for-linux@vger.kernel.org Subject: [PATCH 1/8] nvmem: core: make reg_write() take a const void * Date: Wed, 15 Jul 2026 19:52:17 +0200 Message-ID: <20260715175229.24672-2-linkmauve@linkmauve.fr> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260715175229.24672-1-linkmauve@linkmauve.fr> References: <20260715175229.24672-1-linkmauve@linkmauve.fr> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.84 / 15.00]; RBL_SENDERSCORE(2.00)[172.232.135.74:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; TAGGED_RCPT(0.00)[]; DMARC_DNSFAIL(0.00)[linkmauve.fr : server fail]; PRECEDENCE_BULK(0.00)[]; FREEMAIL_CC(0.00)[linkmauve.fr,linaro.org,baylibre.com,googlemail.com,kernel.org,analog.com,linux.intel.com,intel.com,iki.fi,kemnade.info,atomide.com,arndb.de,linuxfoundation.org,microchip.com,nxp.com,pengutronix.de,gmail.com,mleia.com,linux.alibaba.com,foss.st.com,amd.com,bootlin.com,kumba.dev,sholland.org,garyguo.net,protonmail.com,google.com,umich.edu,collabora.com,nvidia.com,onurozkan.dev,aliel.fr,Stromeko.DE,siemens.com,cab.de,notsyncing.net,iscas.ac.cn,lists.infradead.org,vger.kernel.org,lists.linux.dev,st-md-mailman.stormreply.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sto.lore.kernel.org:rdns,sto.lore.kernel.org:helo,linkmauve.fr:email]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_GT_50(0.00)[88]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74]; FORGED_SENDER_MAILLIST(0.00)[]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-24443-noreply=patchwork.local]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[linkmauve@linkmauve.fr,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 413BD1C2FCB X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
nvmem: make reg_write() take a const void *
|
|
Commit Message
Link Mauve
July 15, 2026, 5:52 p.m. UTC
This callback used to take a mutable void * for no reason, this was
found while drafting the Rust abstraction.
Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
---
drivers/nvmem/core.c | 2 +-
include/linux/nvmem-provider.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Comments
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@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.
On Wed, Jul 15, 2026 at 07:52:17PM +0200, Link Mauve wrote: > This callback used to take a mutable void * for no reason, this was > found while drafting the Rust abstraction. I don't understand how it was compiled. const void * != void * in C and can't be implicitly covered, if I am not mistaken. So, this patch heavily should break the build. What did I miss?
On Wed, Jul 15, 2026 at 09:58:08PM +0300, Andy Shevchenko wrote: > On Wed, Jul 15, 2026 at 07:52:17PM +0200, Link Mauve wrote: > > This callback used to take a mutable void * for no reason, this was > > found while drafting the Rust abstraction. > > I don't understand how it was compiled. const void * != void * in C and can't > be implicitly covered, if I am not mistaken. So, this patch heavily should > break the build. What did I miss? I think I missed a lot of those drivers while compiling, probably because I built it for my target hardware instead of doing a COMPILE_TEST. > > -- > With Best Regards, > Andy Shevchenko > >
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index e871181751f3..202607013054 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -62,7 +62,7 @@ static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset, } static int __nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset, - void *val, size_t bytes) + const void *val, size_t bytes) { int ret; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index f3b13da78aac..e62285836cbb 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); /* used for vendor specific post processing of cell data */ typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int index, unsigned int offset, void *buf,