nvmem: core: Print error on wrong bits DT property
PATCH 1/1 nvmem: core: Print error on wrong bits DT property
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 <[email protected]>
--- drivers/nvmem/core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/nvmem/core.c +5 -0
@@ -806,6 +806,11 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nodif (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);
Signature · 1 line
2.43.0
Srinivas Kandagatla
AppliedQuoted 6 lines · Markus Schneider-Pargmann
The algorithms in nvmem core are built with the constraint that
bit_offset< 8. Ifbit_offsetis 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,
Signature · 1 line
Srinivas Kandagatla <[email protected]>