Skip to content

Commit

Permalink
imx: Check for NULL pointer deref before calling tty_encode_baud_rate
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sascha Hauer authored and Linus Torvalds committed Jun 16, 2009
1 parent 0ccad87 commit 1a2c4b3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/serial/imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1a2c4b3

Please sign in to comment.