Skip to content

Commit

Permalink
[POWERPC] of_serial: Fix possible null dereference.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Neuendorffer authored and Josh Boyer committed Apr 3, 2008
1 parent 5f91925 commit 19a7426
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/serial/of_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 19a7426

Please sign in to comment.