From patchwork Tue Aug 14 13:07:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 10565605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 570F615A6 for ; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480B428C08 for ; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BEA928D2E; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE9F828C08 for ; Tue, 14 Aug 2018 13:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gZrZCJCe7GAmpM4I3eLcTxQp0h36dcSvOLR00Y5P8jA=; b=uMSVftwmrWlpXyYtE6vUsmAHQn JmULC25Z6GWb8o+T5XTzmCU+Bc4L382vvNI5iGobK82oh1Qd+oG8xwZzDz0FUPZWNMB/E5UjYfUvh n47q7xTfTvC1umLjyOvRwbFIQR+4bOFvd0ele1MhX1/fGm7j2YCDSDWdvsiPZ2NM4K/IWa93nXP0u Vl1POlwTkgPrVsfA2FPMt0GT5KshwOQ82yqfmAAmw3P40H5UgHSb1h4zLz3FdSkUw6lJSgnLQeo64 ea8IjTZZMDT49ue+mF/U/yg/UoVa7nWC1n4jYtOWaMDO1MhoKS4TruJ22FueC65Ddd19ttalbxMmL pNcxTTag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ41-0000O3-52; Tue, 14 Aug 2018 13:08:45 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ3y-0000Ht-48 for linux-amlogic@lists.infradead.org; Tue, 14 Aug 2018 13:08:43 +0000 Received: by mail-wm0-x230.google.com with SMTP id f21-v6so12220129wmc.5 for ; Tue, 14 Aug 2018 06:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vbwcmEcIuXUb0QLlRaSWHDMULR+42njV+zBxN930Ol0=; b=rcHY3Puk9MSpXE508H8jTg1o/pvbEjeBd7DxgvabMtf4xD5WHMGRp/92D0oGF/Bgd8 PLdSHQJzNThktxduQhzEFRmxhOlRPFINPloNfsePoik3EfSAAiTSI3VEdvGxVHvHvPJc C6tl+NxV7x3LCxm1BayKuUtIaT/c9anvLQQWXwtQ0wIvw/Nl7gsxy6S+cLlCgSCB5pw+ Yy0QgnV3ewrFSsYHbPPq4vt4p8Wxh6cmbhLCoijRsLAyjbmGW4+QQYGvu5JMsx6V9IeS Zl1gzAFJkDfgoi1XORRbSnSDKNV5tsRKqHNNozoUtsD0ndui5x35BUaQfvle8sfOJGKn iTww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vbwcmEcIuXUb0QLlRaSWHDMULR+42njV+zBxN930Ol0=; b=ONJa6PPRYVjdS+bT6YFL24NiDTBjWywa5gLEY4SivvWG0OWtr5IdX9cj6P6AHpoHoN rQ4eDhOb4uGfvwrstYSYGE6ia9EQ/Ado33+Vk7NjDVMhgpi+VgLYPibKYfKO19cqNi7a fRGI3W0x2ZsjrMqANZUcxCJRnA76KUoDxK/SUeouk0vVVPUH6VN2Arf07botOvQR/STD 3v6XSV/kyWub9puEQsEOvgAaLs0aK91mFTegyOQIlUJ6J+fC143S8A3zK3Q/cUE3H+4C ABaoSk2SW1I9EGJqiLK+AsI6+T6Vzd8HZoGgPNhX29VWDGQEYpoLhfyEDKciweovsnh/ Hwmg== X-Gm-Message-State: AOUpUlHxtCrbUspQzueVE3W1g+VjeNaMeSQa1M4z7r+FYmb+j+YjVdAd 4lJixkkt6Ay+OJk5kydtBJW+Jd7T X-Google-Smtp-Source: AA+uWPxuEx73CO1T8icI3lFNHlz3jE1HlbSXLZc9ieq2BrzSxbTT3e0lQ2gZcWtLzUHJkaJE5p/0sw== X-Received: by 2002:a1c:ca0f:: with SMTP id a15-v6mr10409621wmg.102.1534252108700; Tue, 14 Aug 2018 06:08:28 -0700 (PDT) Received: from sark.homenet.telecomitalia.it ([79.46.68.202]) by smtp.gmail.com with ESMTPSA id r16-v6sm29123997wru.59.2018.08.14.06.08.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 06:08:27 -0700 (PDT) From: Beniamino Galvani To: u-boot@lists.denx.de Subject: [PATCH u-boot 3/3] arm: meson: null-terminate the serial number Date: Tue, 14 Aug 2018 15:07:54 +0200 Message-Id: <20180814130754.19294-4-b.galvani@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814130754.19294-1-b.galvani@gmail.com> References: <20180814130754.19294-1-b.galvani@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180814_060842_325836_510F8F5E X-CRM114-Status: GOOD ( 11.03 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rini , Albert Aribaud , Neil Armstrong , Simon Glass , Beniamino Galvani , linux-amlogic@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Terminate the serial number variable with null to avoid printing trailing garbage. Signed-off-by: Beniamino Galvani --- 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); + } } }