@@ -64,7 +64,7 @@ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size)
void meson_init_env_from_efuse(void)
{
static u8 mac[EFUSE_MAC_SIZE];
- char serial[EFUSE_SN_SIZE];
+ char serial[EFUSE_SN_SIZE + 1];
ssize_t len;
if (!eth_env_get_enetaddr("ethaddr", mac)) {
@@ -77,7 +77,9 @@ void meson_init_env_from_efuse(void)
if (!env_get("serial#")) {
len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial,
EFUSE_SN_SIZE);
- if (len == EFUSE_SN_SIZE)
+ if (len == EFUSE_SN_SIZE) {
+ serial[EFUSE_SN_SIZE] = '\0';
env_set("serial#", serial);
+ }
}
}
Terminate the serial number variable with null to avoid printing trailing garbage. Signed-off-by: Beniamino Galvani <b.galvani@gmail.com> --- arch/arm/mach-meson/sm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)