From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Srinivas Kandagatla <srini@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-kernel@vger.kernel.org, brgl@kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH v2 0/7] nvmem: survive unbind with active consumers
Date: Mon, 23 Feb 2026 11:57:01 +0100 [thread overview]
Message-ID: <20260223-nvmem-unbind-v2-0-0df33a933dca@oss.qualcomm.com> (raw)
Nvmem is one of the subsystems vulnerable to object life-time issues.
The memory nvmem core dereferences is owned by nvmem providers which can
be unbound at any time and even though nvmem devices themselves are
reference-counted, there's no synchronization with the provider modules.
This typically is not a problem because thanks to fw_devlink, consumers
get synchronously unbound before providers but it's enough to pass
fw_devlink=off over the command line, unbind the nvmem controller with
consumers still holding references to it and try to read/write in order
to see fireworks in the kernel log.
User-space can trigger it too if a device (for instance: i2c eeprom on a
cp2112 USB expander) is unplugged halfway through a long read.
Thankfully the design of nvmem is rather sane so it just needs a bit of
encouragement and synchronization.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- add missing SRCU struct cleanup
- improve the teardown path on error in nvmem_register()
- Link to v1: https://lore.kernel.org/r/20260116-nvmem-unbind-v1-0-7bb401ab19a8@oss.qualcomm.com
---
Bartosz Golaszewski (7):
nvmem: remove unused field from struct nvmem_device
nvmem: return -EOPNOTSUPP to in-kernel users on missing callbacks
nvmem: check the return value of gpiod_set_value_cansleep()
nvmem: simplify locking with guard()
nvmem: remove unneeded __nvmem_device_put()
nvmem: split struct nvmem_device into refcounted and provider-owned data
nvmem: synchronize nvmem device unregistering with SRCU
drivers/nvmem/core.c | 295 +++++++++++++++++++++++++---------------------
drivers/nvmem/internals.h | 18 ++-
2 files changed, 173 insertions(+), 140 deletions(-)
---
base-commit: d75756d8d78aa50d454b92665896b3cd0d1077bb
change-id: 20260114-nvmem-unbind-673b52fc84a0
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
next reply other threads:[~2026-02-23 10:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 10:57 Bartosz Golaszewski [this message]
2026-02-23 10:57 ` [PATCH v2 1/7] nvmem: remove unused field from struct nvmem_device Bartosz Golaszewski
2026-03-23 16:00 ` Johan Hovold
2026-02-23 10:57 ` [PATCH v2 2/7] nvmem: return -EOPNOTSUPP to in-kernel users on missing callbacks Bartosz Golaszewski
2026-03-23 16:21 ` Johan Hovold
2026-04-29 15:45 ` Bartosz Golaszewski
2026-02-23 10:57 ` [PATCH v2 3/7] nvmem: check the return value of gpiod_set_value_cansleep() Bartosz Golaszewski
2026-03-23 16:28 ` Johan Hovold
2026-02-23 10:57 ` [PATCH v2 4/7] nvmem: simplify locking with guard() Bartosz Golaszewski
2026-03-23 16:35 ` Johan Hovold
2026-04-29 15:45 ` Bartosz Golaszewski
2026-02-23 10:57 ` [PATCH v2 5/7] nvmem: remove unneeded __nvmem_device_put() Bartosz Golaszewski
2026-03-23 16:44 ` Johan Hovold
2026-04-29 15:45 ` Bartosz Golaszewski
2026-02-23 10:57 ` [PATCH v2 6/7] nvmem: split struct nvmem_device into refcounted and provider-owned data Bartosz Golaszewski
2026-03-17 10:44 ` Johan Hovold
2026-03-17 12:52 ` Bartosz Golaszewski
2026-03-23 16:45 ` Johan Hovold
2026-02-23 10:57 ` [PATCH v2 7/7] nvmem: synchronize nvmem device unregistering with SRCU Bartosz Golaszewski
2026-03-17 11:31 ` Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260223-nvmem-unbind-v2-0-0df33a933dca@oss.qualcomm.com \
--to=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srini@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®