From patchwork Mon Jul 18 17:20:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1657582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ACJwyTAA; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=TIKFWEK5; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lmpdb0625z9sFs for ; Tue, 19 Jul 2022 03:20:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sEFa2bBX551JOhuRJTpqOlR4kB2i8ksBtFo818h7UVY=; b=ACJwyTAA0l0MTx IpslIQnXcnAMBBr8JHDHVoNsiUXGpXQ1tKQB14RsJzSF+sxkXZAE1kcXPXjCvNemlvwUhBHxtM/1M HSV8tiIEXgbRn8oo990/kyRHR2dUcafuIfYS0/0SvTUFTi6T0c/0G4WUZJcSptY/foy66OUqBMjl2 ptk6AditI6UENay0sIid4MnOkGyIMt9t5/4YZgVz9/nULyF4XKNxnqaNIt6s/h7gEmbtFpZNkNR6F BRWSX9V1ZvqtN7kY7DC/ETAqSwyfdqGEzQMwwlzjlUFwVkij4vg3oLe3hYMARH47qg9JmO/tIQ7kY dQUBHO+Sc8bLkMMRTOqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDUQ8-00H78H-Bs; Mon, 18 Jul 2022 17:20:36 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDUQ5-00H763-PI for opensbi@lists.infradead.org; Mon, 18 Jul 2022 17:20:35 +0000 Received: by mail-ed1-x52f.google.com with SMTP id y8so16266319eda.3 for ; Mon, 18 Jul 2022 10:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5yXkVHdqhidiBe9Tml601EENn/Vcx1iTeWJ1zuA7+Fk=; b=TIKFWEK5iWN/DYQCQZSaXUSp9M/gJEv9fkhiT28Sx/q6aGmC0Ltth1SnShYear1mKV GkfZAliOx9XWEHJkhEfCiKKDEZwSFK6CeYh+AUR5w+eeW/4C/Fnw0JHp3hHtxekv/96m QY87g1ETMw79JPETWG4HHryfyqtd8e2hC1Xk7CqeDGS6gOx1pAQDRwUVYtSFa6VovS23 nE7cNNjIPyeBnVG7giWpxyosL0ftDEL0wJwvr34IlwjRb3Bie93rTTPDMoYUMcBkBzGQ eBRgct+WL1KWUusCH60R/Kqf9cdlyg2n79Khd00hnlw9kZo3YT/n2HS8Pz2jark6w8KJ D3Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5yXkVHdqhidiBe9Tml601EENn/Vcx1iTeWJ1zuA7+Fk=; b=511L9/332TajM8lzZIKem+dv6q51RZ5BYlAIJ3+qpw18Y6oyFn8Ch2dp4F54hL6C9w lckPlBY1aahigeJAqE2+GM6bKnz0pn+FG8DtdX5VesvJEmzF+/2Y55l2lk/0OBKW+Vet 1ICGEQeH5nyuDNXK36lHuwV5m5Xu3m4MINGAvIe4cTF5SvqaBjFPX7VCmDoHV49pymt7 Gkj9QLFkH65ga5F7x6TU17G/HxJBvBk5o0PDsELhAUjIaU3Quypaa7DlqhmYTNYIKmhT UKkLTzfaP3B76jNsPUENy5o2TloncHP+MQdQ1UTnY0t66kr5uNByoJYqEfhtBOUF8wtN U5Yg== X-Gm-Message-State: AJIora+IrCRr+wzmYXCf2fmDj/RjWBBfN1dSpbhnr8FgOM6w8dLxKaiZ ZbkTRGc9ks63K0qVVZziJoUApxr9gCXuwg== X-Google-Smtp-Source: AGRyM1t0BNBGUZnNkBLiW/lXc5sczevZTOQvY6N2HdmIKW8qngBKjxs1BREUO9Z3SELZ4E42nl1ttg== X-Received: by 2002:aa7:c0c4:0:b0:43a:20cf:3c68 with SMTP id j4-20020aa7c0c4000000b0043a20cf3c68mr38815421edp.172.1658164832378; Mon, 18 Jul 2022 10:20:32 -0700 (PDT) Received: from localhost (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id 17-20020a170906311100b0072b7d76211dsm2721924ejx.107.2022.07.18.10.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 10:20:32 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Atish Patra , Alistair Francis , Anup Patel , junliang.tan@linux.starfivetech.com Subject: [PATCH 2/4] lib: utils/serial: Initialize platform_uart_data to zero Date: Mon, 18 Jul 2022 19:20:26 +0200 Message-Id: <20220718172028.2006166-3-ajones@ventanamicro.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220718172028.2006166-1-ajones@ventanamicro.com> References: <20220718172028.2006166-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220718_102033_852947_DDC0B9F8 X-CRM114-Status: GOOD ( 12.75 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: While it doesn't look like there are any current cases of using uninitialized data, let's zero all the UART data members to be safe. Zero may not actually be better than a random number in some cases, [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:52f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org While it doesn't look like there are any current cases of using uninitialized data, let's zero all the UART data members to be safe. Zero may not actually be better than a random number in some cases, so all structure members should still be validated before use, but at least zero is usually easier to debug than some random stack garbage... Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/utils/serial/fdt_serial_gaisler.c | 2 +- lib/utils/serial/fdt_serial_shakti.c | 2 +- lib/utils/serial/fdt_serial_sifive.c | 2 +- lib/utils/serial/fdt_serial_uart8250.c | 2 +- lib/utils/serial/fdt_serial_xlnx_uartlite.c | 2 +- platform/fpga/openpiton/platform.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/utils/serial/fdt_serial_gaisler.c b/lib/utils/serial/fdt_serial_gaisler.c index 9a9f9a8b7962..74988e34bcd8 100644 --- a/lib/utils/serial/fdt_serial_gaisler.c +++ b/lib/utils/serial/fdt_serial_gaisler.c @@ -15,7 +15,7 @@ static int serial_gaisler_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - struct platform_uart_data uart; + struct platform_uart_data uart = { 0 }; rc = fdt_parse_gaisler_uart_node(fdt, nodeoff, &uart); if (rc) diff --git a/lib/utils/serial/fdt_serial_shakti.c b/lib/utils/serial/fdt_serial_shakti.c index 4f91419ef53c..0e056303dbb5 100644 --- a/lib/utils/serial/fdt_serial_shakti.c +++ b/lib/utils/serial/fdt_serial_shakti.c @@ -13,7 +13,7 @@ static int serial_shakti_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - struct platform_uart_data uart; + struct platform_uart_data uart = { 0 }; rc = fdt_parse_shakti_uart_node(fdt, nodeoff, &uart); if (rc) diff --git a/lib/utils/serial/fdt_serial_sifive.c b/lib/utils/serial/fdt_serial_sifive.c index f4c833c1573d..3ca10913eee3 100644 --- a/lib/utils/serial/fdt_serial_sifive.c +++ b/lib/utils/serial/fdt_serial_sifive.c @@ -15,7 +15,7 @@ static int serial_sifive_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - struct platform_uart_data uart; + struct platform_uart_data uart = { 0 }; rc = fdt_parse_sifive_uart_node(fdt, nodeoff, &uart); if (rc) diff --git a/lib/utils/serial/fdt_serial_uart8250.c b/lib/utils/serial/fdt_serial_uart8250.c index 544b7416de42..0b95f2d9e44e 100644 --- a/lib/utils/serial/fdt_serial_uart8250.c +++ b/lib/utils/serial/fdt_serial_uart8250.c @@ -15,7 +15,7 @@ static int serial_uart8250_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - struct platform_uart_data uart; + struct platform_uart_data uart = { 0 }; rc = fdt_parse_uart8250_node(fdt, nodeoff, &uart); if (rc) diff --git a/lib/utils/serial/fdt_serial_xlnx_uartlite.c b/lib/utils/serial/fdt_serial_xlnx_uartlite.c index 466e16e82d8c..9f04aea3673b 100644 --- a/lib/utils/serial/fdt_serial_xlnx_uartlite.c +++ b/lib/utils/serial/fdt_serial_xlnx_uartlite.c @@ -15,7 +15,7 @@ static int serial_xlnx_uartlite_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - struct platform_uart_data uart; + struct platform_uart_data uart = { 0 }; rc = fdt_parse_xlnx_uartlite_node(fdt, nodeoff, &uart); if (rc) diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 7ca21236bfef..5ff7d200aba9 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -69,7 +69,7 @@ static struct aclint_mtimer_data mtimer = { static int openpiton_early_init(bool cold_boot) { void *fdt; - struct platform_uart_data uart_data; + struct platform_uart_data uart_data = { 0 }; struct plic_data plic_data; unsigned long aclint_freq; uint64_t clint_addr;