Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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 <stephen.neuendorffer@xilinx.com>
Signed-off-by: John Linn <john.linn@xilinx.com>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>

authored by

Stephen Neuendorffer and committed by
Josh Boyer
19a74263 5f91925c

+3 -1
+3 -1
drivers/serial/of_serial.c
··· 56 56 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 57 57 | UPF_FIXED_PORT; 58 58 port->dev = &ofdev->dev; 59 - port->custom_divisor = *clk / (16 * (*spd)); 59 + /* If current-speed was set, then try not to change it. */ 60 + if (spd) 61 + port->custom_divisor = *clk / (16 * (*spd)); 60 62 61 63 return 0; 62 64 }