From 1a2c4b3147ac0645605d6def2855478861d9361b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 16 Jun 2009 17:02:15 +0100 Subject: imx: Check for NULL pointer deref before calling tty_encode_baud_rate Signed-off-by: Sascha Hauer Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/serial/imx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index 285b414f305..5d7b58f1fe4 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -924,11 +924,13 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios, rational_best_approximation(16 * div * baud, sport->port.uartclk, 1 << 16, 1 << 16, &num, &denom); - tdiv64 = sport->port.uartclk; - tdiv64 *= num; - do_div(tdiv64, denom * 16 * div); - tty_encode_baud_rate(sport->port.info->port.tty, - (speed_t)tdiv64, (speed_t)tdiv64); + if (port->info && port->info->port.tty) { + tdiv64 = sport->port.uartclk; + tdiv64 *= num; + do_div(tdiv64, denom * 16 * div); + tty_encode_baud_rate(sport->port.info->port.tty, + (speed_t)tdiv64, (speed_t)tdiv64); + } num -= 1; denom -= 1; -- cgit v1.2.3