Commit 1401ebda89ebf3156984c175209f630e0844f6ce

Authored by David Müller
Committed by Greg Kroah-Hartman
1 parent 71378785b6

serial: 8250_pci: fix divide error bug if baud rate is 0

commit 6f210c18c1c0f016772c8cd51ae12a02bfb9e7ef upstream.

Since commit 21947ba654a6 ("serial: 8250_pci: replace switch-case by
formula"), the 8250 driver crashes in the byt_set_termios() function
with a divide error. This is caused by the fact that a baud rate of 0 (B0)
is not handled properly. Fix it by falling back to B9600 in this case.

Signed-off-by: David Müller <d.mueller@elsoft.ch>
Fixes: 21947ba654a6 ("serial: 8250_pci: replace switch-case by formula")
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

drivers/tty/serial/8250/8250_pci.c
... ... @@ -1401,6 +1401,9 @@
1401 1401 unsigned long m, n;
1402 1402 u32 reg;
1403 1403  
  1404 + /* Gracefully handle the B0 case: fall back to B9600 */
  1405 + fuart = fuart ? fuart : 9600 * 16;
  1406 +
1404 1407 /* Get Fuart closer to Fref */
1405 1408 fuart *= rounddown_pow_of_two(fref / fuart);
1406 1409