[PATCH 05/11] nvmem: reference cell entries independently of their provider list
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 17 11:48:25 PST 2026
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] nvmem: missing layout module reference in
nvmem_cell_get_from_lookup() [1]
--
commit dca0d45c01829b24f06f31f8f551815c804db7a1
Author: James Hilliard <james.hilliard1 at gmail.com>
nvmem: reference cell entries independently of their provider list
This commit adds a kref to struct nvmem_cell_entry so that cell handles hold a
reference to their cell entry independently of the provider's cell list.
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 65d89498edeb3..70b6126886d9f 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
[ ... ]
> @@ -1408,8 +1421,10 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
> cell = ERR_PTR(-ENOENT);
> } else {
> cell = nvmem_create_cell(cell_entry, con_id, 0);
> - if (IS_ERR(cell))
> + if (IS_ERR(cell)) {
> + nvmem_cell_entry_put(cell_entry);
> nvmem_device_put(nvmem);
> + }
> }
> break;
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but does
nvmem_cell_get_from_lookup() miss acquiring a layout module reference
[1] before creating the cell?
Unlike of_nvmem_cell_get(), this path never calls
nvmem_layout_module_get_optional(), yet nvmem_cell_put() unconditionally calls
nvmem_layout_module_put(nvmem). Releasing a cell obtained from a lookup table
on a device with a layout will underflow the layout module refcount, allowing
the module to be unloaded while still in use.
[1] https://sashiko.dev/#/bug/linux-4d65574f-cdef-4be7-87ff-b1c197e66c04
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-submit-nvmem-provider-lifetime-v1-v1-0-3cfbd48812b5@gmail.com?part=5
More information about the linux-mtd
mailing list