* [PATCH] nvmem: core: Print error on wrong bits DT property
@ 2024-01-30 10:07 Markus Schneider-Pargmann
2024-02-21 7:12 ` Srinivas Kandagatla
0 siblings, 1 reply; 2+ messages in thread
From: Markus Schneider-Pargmann @ 2024-01-30 10:07 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Greg Kroah-Hartman, Miquel Raynal, Michael Walle,
Rafał Miłecki, linux-kernel, Markus Schneider-Pargmann
The algorithms in nvmem core are built with the constraint that
bit_offset < 8. If bit_offset is greater the results are wrong. Print an
error if the devicetree 'bits' property is outside of the valid range
and abort parsing.
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---
drivers/nvmem/core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 980123fb4dde..a9832b5a608e 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -806,6 +806,11 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
if (addr && len == (2 * sizeof(u32))) {
info.bit_offset = be32_to_cpup(addr++);
info.nbits = be32_to_cpup(addr);
+ if (info.bit_offset >= BITS_PER_BYTE || info.nbits < 1) {
+ dev_err(dev, "nvmem: invalid bits on %pOF\n", child);
+ of_node_put(child);
+ return -EINVAL;
+ }
}
info.np = of_node_get(child);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmem: core: Print error on wrong bits DT property
2024-01-30 10:07 [PATCH] nvmem: core: Print error on wrong bits DT property Markus Schneider-Pargmann
@ 2024-02-21 7:12 ` Srinivas Kandagatla
0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2024-02-21 7:12 UTC (permalink / raw)
To: Markus Schneider-Pargmann
Cc: Greg Kroah-Hartman, Miquel Raynal, Michael Walle,
Rafał Miłecki, linux-kernel
On Tue, 30 Jan 2024 11:07:14 +0100, Markus Schneider-Pargmann wrote:
> The algorithms in nvmem core are built with the constraint that
> bit_offset < 8. If bit_offset is greater the results are wrong. Print an
> error if the devicetree 'bits' property is outside of the valid range
> and abort parsing.
>
>
Applied, thanks!
[1/1] nvmem: core: Print error on wrong bits DT property
commit: 8bb130f38373b5e405b7d81c6ebc36107e518a99
Best regards,
--
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-21 7:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 10:07 [PATCH] nvmem: core: Print error on wrong bits DT property Markus Schneider-Pargmann
2024-02-21 7:12 ` Srinivas Kandagatla
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®