serial: of-serial: fix uninitialized kmalloc variable
authorJingchang Lu <jingchang.lu@freescale.com>
Tue, 21 Oct 2014 08:50:21 +0000 (16:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Nov 2014 04:12:02 +0000 (20:12 -0800)
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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/of_serial.c

index 8bc2563335ae34ba2ae45bf55117c808d0b219c5..56982da4a9e9f77ac4fd062f95c00724cc7ade34 100644 (file)
@@ -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;