]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
nvmem: meson-mx-efuse: fix reading from an offset other than 0
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Fri, 15 Dec 2017 13:42:04 +0000 (13:42 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Dec 2017 08:56:03 +0000 (09:56 +0100)
commit793ae04c46cf054a6342671de3fabb1b5131a880
tree38f1d2671176eea2aabe39d3e48102227c314ca9
parentafe3eb60fa82a5d812378530b50755f58acc029c
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: 8caef1fa9176 ("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>
drivers/nvmem/meson-mx-efuse.c