imx: Check for NULL pointer deref before calling tty_encode_baud_rate
authorSascha Hauer <s.hauer@pengutronix.de>
Tue, 16 Jun 2009 16:02:15 +0000 (17:02 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Jun 2009 19:01:17 +0000 (12:01 -0700)
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/serial/imx.c

index 285b414f30546d0a89285f823d802979adbbcac9..5d7b58f1fe42a38596072ba9355d619ffcfd54a2 100644 (file)
@@ -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;