Skip to content

Commit 8a42d3f

Browse files
xdarklightgregkh
authored andcommitted
nvmem: meson-mx-efuse: fix reading from an offset other than 0
meson_mx_efuse_read calculates the address internal to the eFuse based on the offset and the word size. This works fine with any given offset. However, the offset is also included when writing to the output buffer. This means that reading 4 bytes at offset 500 tries to write beyond the array allocated by the nvmem core as it wants to write the 4 bytes to "buffer address + offset (500)". This issue did not show up in the previous tests since no driver uses any value from the eFuse yet and reading the eFuse via sysfs simply reads the whole eFuse, starting at offset 0. Fix this by only including the offset in the internal address calculation. Fixes: 8caef1f ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs") Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7f3dc00 commit 8a42d3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/nvmem/meson-mx-efuse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
156156
MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE,
157157
MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE);
158158

159-
for (i = offset; i < offset + bytes; i += efuse->config.word_size) {
160-
addr = i / efuse->config.word_size;
159+
for (i = 0; i < bytes; i += efuse->config.word_size) {
160+
addr = (offset + i) / efuse->config.word_size;
161161

162162
err = meson_mx_efuse_read_addr(efuse, addr, &tmp);
163163
if (err)

0 commit comments

Comments
 (0)