]> err.no Git - linux-2.6/commitdiff
[POWERPC] of_serial: Fix possible null dereference.
authorStephen Neuendorffer <stephen.neuendorffer@xilinx.com>
Wed, 2 Apr 2008 16:52:13 +0000 (03:52 +1100)
committerJosh Boyer <jwboyer@linux.vnet.ibm.com>
Thu, 3 Apr 2008 01:29:32 +0000 (20:29 -0500)
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 <stephen.neuendorffer@xilinx.com>
Signed-off-by: John Linn <john.linn@xilinx.com>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
drivers/serial/of_serial.c

index c0e50a461055b85a5b4dd8e6996692679e62c1c1..8aacfb78deabe03e08ca8d8b4df0e6235eff35ee 100644 (file)
@@ -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;
 }