From 19a74263f49dce2b96e2213f7f4c029cedbbf0ce Mon Sep 17 00:00:00 2001 From: Stephen Neuendorffer Date: Thu, 3 Apr 2008 03:52:13 +1100 Subject: [POWERPC] of_serial: Fix possible null dereference. The of_serial driver queries the current-speed property and attempts to use it to register the custom_divisor property of the uart_port. However, if current-speed is not set, then this code will dereference a bad pointer. The fix is to only set custom_divisor when a current-speed property appears in the device tree. Signed-off-by: Stephen Neuendorffer Signed-off-by: John Linn Signed-off-by: Josh Boyer --- drivers/serial/of_serial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/serial/of_serial.c') diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c index c0e50a461055..8aacfb78deab 100644 --- a/drivers/serial/of_serial.c +++ b/drivers/serial/of_serial.c @@ -56,7 +56,9 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev, port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_FIXED_PORT; port->dev = &ofdev->dev; - port->custom_divisor = *clk / (16 * (*spd)); + /* If current-speed was set, then try not to change it. */ + if (spd) + port->custom_divisor = *clk / (16 * (*spd)); return 0; } -- cgit v1.2.3-59-g8ed1b