]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - drivers/tty/serial/sh-sci.c
serial: sh-sci: Avoid overflow in sci_baud_calc_hscif()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 13 Nov 2015 16:04:56 +0000 (17:04 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 17 Dec 2015 10:18:29 +0000 (11:18 +0100)
commitde01e6cd0b100bac088b1d59a7040ebe2af64f1c
treeaeaefb1b24c68ad3f41a7769bcc29e08279e39e4
parent95a2703e36530c09a9416321ec21c062f3e91d01
serial: sh-sci: Avoid overflow in sci_baud_calc_hscif()

If bps >= 1048576, the multiplication of the predivider and "bps" will
overflow, and both br and err will contain bogus values.
Skip the current and all higher clock select predividers when overflow
is detected.  Simplify the calculations using intermediates while we're
at it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sh-sci.c