Skip to content

Commit

Permalink
nvmem: meson-mx-efuse: allow reading data smaller than word_size
Browse files Browse the repository at this point in the history
Some Amlogic boards store the Ethernet MAC address inside the eFuse. The
Ethernet MAC address uses 6 bytes. The existing logic in
meson_mx_efuse_read() would write beyond the end of the data buffer when
trying to read data with a size that is not aligned to word_size (4
bytes on Meson8, Meson8b and Meson8m2).

Calculate the remaining data to copy inside meson_mx_efuse_read() so
reading 6 bytes doesn't write beyond the end of the data buffer.

Signed-off-by: Martin Blumenstingl <[email protected]>
Reviewed-by: Neil Armstrong <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
xdarklight authored and gregkh committed Aug 18, 2019
1 parent 2ac00e3 commit cb6b0a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/nvmem/meson-mx-efuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset,
if (err)
break;

memcpy(buf + i, &tmp, efuse->config.word_size);
memcpy(buf + i, &tmp,
min_t(size_t, bytes - i, efuse->config.word_size));
}

meson_mx_efuse_mask_bits(efuse, MESON_MX_EFUSE_CNTL1,
Expand Down

0 comments on commit cb6b0a3

Please sign in to comment.