From: James Hilliard <james.hilliard1@gmail.com>
To: Srinivas Kandagatla <srini@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Markus Schneider-Pargmann <msp@baylibre.com>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>
Subject: [PATCH] nvmem: core: validate DT cell bits before allocating the name
Date: Tue, 17 Nov 2026 15:14:46 -0700 [thread overview]
Message-ID: <20261117-submit-nvmem-dt-cell-name-v1-v1-1-491cee782e6e@gmail.com> (raw)
An invalid bits property makes nvmem_add_cells_from_dt() return before
it frees the cell name. Allocate the name after validating the property,
and fail before invoking the provider fixup if allocation fails.
Fixes: def3173d4f17 ("nvmem: core: Print error on wrong bits DT property")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/sashiko-outbox-219531@kernel.org/
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/nvmem/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 7d4cce8e2742..56e04c030c7f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -819,7 +819,6 @@ int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
info.offset = be32_to_cpup(addr++);
info.bytes = be32_to_cpup(addr);
- info.name = kasprintf(GFP_KERNEL, "%pOFn", child);
addr = of_get_property(child, "bits", &len);
if (addr && len == (2 * sizeof(u32))) {
@@ -833,6 +832,9 @@ int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
}
}
+ info.name = kasprintf(GFP_KERNEL, "%pOFn", child);
+ if (!info.name)
+ return -ENOMEM;
info.np = of_node_get(child);
if (nvmem->fixup_dt_cell_info)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
base-tree: https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git for-fixes
change-id: 20261117-submit-nvmem-dt-cell-name-v1-e51d1f6674dd
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
next reply other threads:[~2026-11-17 22:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 22:14 James Hilliard [this message]
2026-11-24 21:20 ` Srinivas Kandagatla
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=20261117-submit-nvmem-dt-cell-name-v1-v1-1-491cee782e6e@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=msp@baylibre.com \
--cc=srini@kernel.org \
--cc=stable@vger.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®