From: b.galvani@gmail.com (Beniamino Galvani)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH u-boot 3/3] arm: meson: null-terminate the serial number
Date: Tue, 14 Aug 2018 15:07:54 +0200 [thread overview]
Message-ID: <20180814130754.19294-4-b.galvani@gmail.com> (raw)
In-Reply-To: <20180814130754.19294-1-b.galvani@gmail.com>
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(-)
diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c
index 2628591fe6..23eafe87b4 100644
--- a/arch/arm/mach-meson/sm.c
+++ b/arch/arm/mach-meson/sm.c
@@ -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);
+ }
}
}
--
2.17.1
prev parent reply other threads:[~2018-08-14 13:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-14 13:07 [PATCH u-boot 0/3] amlogic: clean up board files Beniamino Galvani
2018-08-14 13:07 ` [PATCH u-boot 1/3] boards: amlogic: remove ethernet gpio reset code from boards Beniamino Galvani
2018-08-20 8:36 ` Neil Armstrong
2018-08-24 20:10 ` [U-Boot, u-boot, " Tom Rini
2018-08-14 13:07 ` [PATCH u-boot 2/3] boards: amlogic: use common function for environment initialization Beniamino Galvani
2018-08-20 8:43 ` Neil Armstrong
2018-08-14 13:07 ` Beniamino Galvani [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180814130754.19294-4-b.galvani@gmail.com \
--to=b.galvani@gmail.com \
--cc=linus-amlogic@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).