OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <ajones@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 2/4] lib: utils/serial: Initialize platform_uart_data to zero
Date: Mon, 18 Jul 2022 19:20:26 +0200	[thread overview]
Message-ID: <20220718172028.2006166-3-ajones@ventanamicro.com> (raw)
In-Reply-To: <20220718172028.2006166-1-ajones@ventanamicro.com>

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 <ajones@ventanamicro.com>
---
 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;
-- 
2.36.1



  parent reply	other threads:[~2022-07-18 17:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 17:20 [PATCH 0/4] lib: utils/serial: Collection of UART code improvements Andrew Jones
2022-07-18 17:20 ` [PATCH 1/4] lib: utils/fdt: Factor out common uart node code Andrew Jones
2022-07-30  5:24   ` Anup Patel
2022-07-30 10:19     ` Anup Patel
2022-07-18 17:20 ` Andrew Jones [this message]
2022-07-18 17:42   ` [PATCH 2/4] lib: utils/serial: Initialize platform_uart_data to zero Jessica Clarke
2022-07-18 18:35     ` Andrew Jones
2022-07-18 18:39       ` Jessica Clarke
2022-07-19 10:30         ` Andrew Jones
2022-07-30  5:25   ` Anup Patel
2022-07-30 10:20     ` Anup Patel
2022-07-18 17:20 ` [PATCH 3/4] lib: serial: Clean up coding style in sifive-uart.c Andrew Jones
2022-07-20 15:13   ` Xiang W
2022-07-30  5:27   ` Anup Patel
2022-07-30 10:20     ` Anup Patel
2022-07-18 17:20 ` [PATCH 4/4] lib: utils/serial: Ensure baudrate is non-zero before using Andrew Jones
2022-07-20 15:12   ` Xiang W
2022-07-20 17:16     ` Andrew Jones
2022-07-20 17:25       ` Xiang W
2022-07-21  5:35         ` Andrew Jones
2022-07-30  5:31   ` Anup Patel
2022-07-30 10:21     ` Anup Patel

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=20220718172028.2006166-3-ajones@ventanamicro.com \
    --to=ajones@ventanamicro.com \
    --cc=opensbi@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