mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] uart drivers: use xzalloc instead of xmalloc
Date: Fri, 23 Dec 2011 11:22:01 +0100	[thread overview]
Message-ID: <1324635721-20195-1-git-send-email-s.hauer@pengutronix.de> (raw)

The flags in struct console_device have to be initialized
to zero. Otherwise the following can happen:

- console_register sets the initial baudrate of a new console
  before we set the global console init state to CONSOLE_INIT_FULL.
- In console_baudrate_set we test whether the current console is
  active which may be true because of unitialized flags.
- we then call getc() to wait for the user to accept the new settings
  and we are stuck because of the CONSOLE_UNINITIALIZED state
  we will never get anything from getc().

Looking back this explains some cases for me when barebox refused
to start and I really wonder why this did not become a more visible
problem before.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/serial/amba-pl011.c         |    2 +-
 drivers/serial/atmel.c              |    2 +-
 drivers/serial/serial_altera.c      |    2 +-
 drivers/serial/serial_altera_jtag.c |    2 +-
 drivers/serial/serial_blackfin.c    |    2 +-
 drivers/serial/serial_imx.c         |    2 +-
 drivers/serial/serial_netx.c        |    2 +-
 drivers/serial/serial_pl010.c       |    2 +-
 drivers/serial/serial_s3c24x0.c     |    2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 148bdbf..56f6f15 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -159,7 +159,7 @@ static int pl011_probe(struct device_d *dev)
 	struct amba_uart_port *uart;
 	struct console_device *cdev;
 
-	uart = xmalloc(sizeof(struct amba_uart_port));
+	uart = xzalloc(sizeof(struct amba_uart_port));
 	uart->clk = clk_get(dev, NULL);
 
 	if (IS_ERR(uart->clk))
diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index 9ba4ca9..de58465 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -399,7 +399,7 @@ static int atmel_serial_probe(struct device_d *dev)
 	struct atmel_uart_port *uart;
 	struct console_device *cdev;
 
-	uart = xmalloc(sizeof(struct atmel_uart_port));
+	uart = xzalloc(sizeof(struct atmel_uart_port));
 	cdev = &uart->uart;
 	dev->type_data = cdev;
 	cdev->dev = dev;
diff --git a/drivers/serial/serial_altera.c b/drivers/serial/serial_altera.c
index 8fd5d8a..e4d3c40 100644
--- a/drivers/serial/serial_altera.c
+++ b/drivers/serial/serial_altera.c
@@ -85,7 +85,7 @@ static int altera_serial_probe(struct device_d *dev)
 	struct console_device *cdev;
 	struct altera_serial_priv *priv;
 
-	priv = xmalloc(sizeof(*priv));
+	priv = xzalloc(sizeof(*priv));
 	cdev = &priv->cdev;
 
 	priv->regs = dev_request_mem_region(dev, 0);
diff --git a/drivers/serial/serial_altera_jtag.c b/drivers/serial/serial_altera_jtag.c
index 3e1b0cf..140ca26 100644
--- a/drivers/serial/serial_altera_jtag.c
+++ b/drivers/serial/serial_altera_jtag.c
@@ -90,7 +90,7 @@ static int altera_serial_jtag_probe(struct device_d *dev) {
 	struct console_device *cdev;
 	struct altera_serial_jtag_priv *priv;
 
-	priv = xmalloc(sizeof(*priv));
+	priv = xzalloc(sizeof(*priv));
 	cdev = &priv->cdev;
 
 	priv->regs = dev_request_mem_region(dev, 0);
diff --git a/drivers/serial/serial_blackfin.c b/drivers/serial/serial_blackfin.c
index 9ad5579..d38a06c 100644
--- a/drivers/serial/serial_blackfin.c
+++ b/drivers/serial/serial_blackfin.c
@@ -115,7 +115,7 @@ static int blackfin_serial_probe(struct device_d *dev)
 {
 	struct console_device *cdev;
 
-	cdev = xmalloc(sizeof(struct console_device));
+	cdev = xzalloc(sizeof(struct console_device));
 	dev->type_data = cdev;
 	cdev->dev = dev;
 	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index 4923dcb..8547f36 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -320,7 +320,7 @@ static int imx_serial_probe(struct device_d *dev)
 	struct imx_serial_priv *priv;
 	uint32_t val;
 
-	priv = xmalloc(sizeof(*priv));
+	priv = xzalloc(sizeof(*priv));
 	cdev = &priv->cdev;
 
 	priv->regs = dev_request_mem_region(dev, 0);
diff --git a/drivers/serial/serial_netx.c b/drivers/serial/serial_netx.c
index a3273e9..4f4fb2d 100644
--- a/drivers/serial/serial_netx.c
+++ b/drivers/serial/serial_netx.c
@@ -140,7 +140,7 @@ static int netx_serial_probe(struct device_d *dev)
 {
 	struct console_device *cdev;
 
-	cdev = xmalloc(sizeof(struct console_device));
+	cdev = xzalloc(sizeof(struct console_device));
 	dev->type_data = cdev;
 	dev->priv = dev_request_mem_region(dev, 0);
 	cdev->dev = dev;
diff --git a/drivers/serial/serial_pl010.c b/drivers/serial/serial_pl010.c
index cb87541..e11406d 100644
--- a/drivers/serial/serial_pl010.c
+++ b/drivers/serial/serial_pl010.c
@@ -141,7 +141,7 @@ static int pl010_probe(struct device_d *dev)
 {
 	struct console_device *cdev;
 
-	cdev = xmalloc(sizeof(struct console_device));
+	cdev = xzalloc(sizeof(struct console_device));
 	dev->type_data = cdev;
 	dev->priv = dev_request_mem_region(dev, 0);
 	cdev->dev = dev;
diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c
index abc08e0..1e27d48 100644
--- a/drivers/serial/serial_s3c24x0.c
+++ b/drivers/serial/serial_s3c24x0.c
@@ -129,7 +129,7 @@ static int s3c24x0_serial_probe(struct device_d *dev)
 {
 	struct console_device *cdev;
 
-	cdev = xmalloc(sizeof(struct console_device));
+	cdev = xzalloc(sizeof(struct console_device));
 	dev->type_data = cdev;
 	dev->priv = dev_request_mem_region(dev, 0);
 	cdev->dev = dev;
-- 
1.7.7.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2011-12-23 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-23 10:22 Sascha Hauer [this message]
2012-01-02 13:50 tlsf patches Sascha Hauer
2012-01-02 13:50 ` [PATCH] uart drivers: use xzalloc instead of xmalloc Sascha Hauer

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=1324635721-20195-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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