linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: of-serial: fix uninitialized kmalloc variable
@ 2014-10-21  8:50 Jingchang Lu
  2014-10-21 10:11 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Jingchang Lu @ 2014-10-21  8:50 UTC (permalink / raw)
  To: gregkh
  Cc: josephl, peter, arnd, linux-serial, linux-kernel,
	linux-arm-kernel, Jingchang Lu

The info pointer points to an uninitialized kmalloced space.
If a device doesn't have clk property, then info->clk may
have unpredicated value and cause call trace. So use kzalloc
to make sure it is NULL initialized.

Signed-off-by: Jingchang Lu <jingchang.lu@freescale.com>
---
 drivers/tty/serial/of_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 8bc2563..56982da4 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -158,7 +158,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 	if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL))
 		return -EBUSY;
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (info == NULL)
 		return -ENOMEM;
 
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: of-serial: fix uninitialized kmalloc variable
  2014-10-21  8:50 [PATCH] serial: of-serial: fix uninitialized kmalloc variable Jingchang Lu
@ 2014-10-21 10:11 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2014-10-21 10:11 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Jingchang Lu, gregkh, peter, linux-kernel, linux-serial, josephl

On Tuesday 21 October 2014 16:50:21 Jingchang Lu wrote:
> The info pointer points to an uninitialized kmalloced space.
> If a device doesn't have clk property, then info->clk may
> have unpredicated value and cause call trace. So use kzalloc
> to make sure it is NULL initialized.
> 
> Signed-off-by: Jingchang Lu <jingchang.lu@freescale.com>
> 

Acked-by: Arnd Bergmann <arnd@arndb.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-21 10:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21  8:50 [PATCH] serial: of-serial: fix uninitialized kmalloc variable Jingchang Lu
2014-10-21 10:11 ` Arnd Bergmann

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).