* [PATCH resend 1/2] tty: omap-serial: fix division by zero
[not found] <20140924080852.GA28215@kroah.com>
@ 2014-09-25 9:19 ` Frans Klaver
2014-09-25 10:16 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Frans Klaver @ 2014-09-25 9:19 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: stable, Frans Klaver, Jiri Slaby, linux-serial, linux-kernel,
linux-omap
If the chosen baud rate is large enough (e.g. 3.5 megabaud), the
calculated n values in serial_omap_is_baud_mode16() may become 0. This
causes a division by zero when calculating the difference between
calculated and desired baud rates. To prevent this, cap the n13 and n16
values on 1.
Division by zero in kernel.
[<c00132e0>] (unwind_backtrace) from [<c00112ec>] (show_stack+0x10/0x14)
[<c00112ec>] (show_stack) from [<c01ed7bc>] (Ldiv0+0x8/0x10)
[<c01ed7bc>] (Ldiv0) from [<c023805c>] (serial_omap_baud_is_mode16+0x4c/0x68)
[<c023805c>] (serial_omap_baud_is_mode16) from [<c02396b4>] (serial_omap_set_termios+0x90/0x8d8)
[<c02396b4>] (serial_omap_set_termios) from [<c0230a0c>] (uart_change_speed+0xa4/0xa8)
[<c0230a0c>] (uart_change_speed) from [<c0231798>] (uart_set_termios+0xa0/0x1fc)
[<c0231798>] (uart_set_termios) from [<c022bb44>] (tty_set_termios+0x248/0x2c0)
[<c022bb44>] (tty_set_termios) from [<c022c17c>] (set_termios+0x248/0x29c)
[<c022c17c>] (set_termios) from [<c022c3e4>] (tty_mode_ioctl+0x1c8/0x4e8)
[<c022c3e4>] (tty_mode_ioctl) from [<c0227e70>] (tty_ioctl+0xa94/0xb18)
[<c0227e70>] (tty_ioctl) from [<c00cf45c>] (do_vfs_ioctl+0x4a0/0x560)
[<c00cf45c>] (do_vfs_ioctl) from [<c00cf568>] (SyS_ioctl+0x4c/0x74)
[<c00cf568>] (SyS_ioctl) from [<c000e480>] (ret_fast_syscall+0x0/0x30)
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
---
Resend to add stable@vger.kernel.org to CC. As far as I know, this applies to
v3.9 and up.
Thanks,
Frans
drivers/tty/serial/omap-serial.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index d017cec..e454b7c 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -254,8 +254,16 @@ serial_omap_baud_is_mode16(struct uart_port *port, unsigned int baud)
{
unsigned int n13 = port->uartclk / (13 * baud);
unsigned int n16 = port->uartclk / (16 * baud);
- int baudAbsDiff13 = baud - (port->uartclk / (13 * n13));
- int baudAbsDiff16 = baud - (port->uartclk / (16 * n16));
+ int baudAbsDiff13;
+ int baudAbsDiff16;
+
+ if (n13 == 0)
+ n13 = 1;
+ if (n16 == 0)
+ n16 = 1;
+
+ baudAbsDiff13 = baud - (port->uartclk / (13 * n13));
+ baudAbsDiff16 = baud - (port->uartclk / (16 * n16));
if (baudAbsDiff13 < 0)
baudAbsDiff13 = -baudAbsDiff13;
if (baudAbsDiff16 < 0)
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH resend 1/2] tty: omap-serial: fix division by zero
2014-09-25 9:19 ` [PATCH resend 1/2] tty: omap-serial: fix division by zero Frans Klaver
@ 2014-09-25 10:16 ` Greg Kroah-Hartman
2014-09-25 10:24 ` Frans Klaver
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2014-09-25 10:16 UTC (permalink / raw)
To: Frans Klaver; +Cc: stable, Jiri Slaby, linux-serial, linux-kernel, linux-omap
On Thu, Sep 25, 2014 at 11:19:51AM +0200, Frans Klaver wrote:
> If the chosen baud rate is large enough (e.g. 3.5 megabaud), the
> calculated n values in serial_omap_is_baud_mode16() may become 0. This
> causes a division by zero when calculating the difference between
> calculated and desired baud rates. To prevent this, cap the n13 and n16
> values on 1.
>
> Division by zero in kernel.
> [<c00132e0>] (unwind_backtrace) from [<c00112ec>] (show_stack+0x10/0x14)
> [<c00112ec>] (show_stack) from [<c01ed7bc>] (Ldiv0+0x8/0x10)
> [<c01ed7bc>] (Ldiv0) from [<c023805c>] (serial_omap_baud_is_mode16+0x4c/0x68)
> [<c023805c>] (serial_omap_baud_is_mode16) from [<c02396b4>] (serial_omap_set_termios+0x90/0x8d8)
> [<c02396b4>] (serial_omap_set_termios) from [<c0230a0c>] (uart_change_speed+0xa4/0xa8)
> [<c0230a0c>] (uart_change_speed) from [<c0231798>] (uart_set_termios+0xa0/0x1fc)
> [<c0231798>] (uart_set_termios) from [<c022bb44>] (tty_set_termios+0x248/0x2c0)
> [<c022bb44>] (tty_set_termios) from [<c022c17c>] (set_termios+0x248/0x29c)
> [<c022c17c>] (set_termios) from [<c022c3e4>] (tty_mode_ioctl+0x1c8/0x4e8)
> [<c022c3e4>] (tty_mode_ioctl) from [<c0227e70>] (tty_ioctl+0xa94/0xb18)
> [<c0227e70>] (tty_ioctl) from [<c00cf45c>] (do_vfs_ioctl+0x4a0/0x560)
> [<c00cf45c>] (do_vfs_ioctl) from [<c00cf568>] (SyS_ioctl+0x4c/0x74)
> [<c00cf568>] (SyS_ioctl) from [<c000e480>] (ret_fast_syscall+0x0/0x30)
>
> Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
> ---
> Resend to add stable@vger.kernel.org to CC. As far as I know, this applies to
> v3.9 and up.
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
</formletter>
I'll take care of this, but go read that file for your next time...
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH resend 1/2] tty: omap-serial: fix division by zero
2014-09-25 10:16 ` Greg Kroah-Hartman
@ 2014-09-25 10:24 ` Frans Klaver
0 siblings, 0 replies; 3+ messages in thread
From: Frans Klaver @ 2014-09-25 10:24 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: stable, Jiri Slaby, linux-serial, linux-kernel, linux-omap
On Thu, Sep 25, 2014 at 12:16:28PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Sep 25, 2014 at 11:19:51AM +0200, Frans Klaver wrote:
> > If the chosen baud rate is large enough (e.g. 3.5 megabaud), the
> > calculated n values in serial_omap_is_baud_mode16() may become 0. This
> > causes a division by zero when calculating the difference between
> > calculated and desired baud rates. To prevent this, cap the n13 and n16
> > values on 1.
> >
> > Division by zero in kernel.
> > [<c00132e0>] (unwind_backtrace) from [<c00112ec>] (show_stack+0x10/0x14)
> > [<c00112ec>] (show_stack) from [<c01ed7bc>] (Ldiv0+0x8/0x10)
> > [<c01ed7bc>] (Ldiv0) from [<c023805c>] (serial_omap_baud_is_mode16+0x4c/0x68)
> > [<c023805c>] (serial_omap_baud_is_mode16) from [<c02396b4>] (serial_omap_set_termios+0x90/0x8d8)
> > [<c02396b4>] (serial_omap_set_termios) from [<c0230a0c>] (uart_change_speed+0xa4/0xa8)
> > [<c0230a0c>] (uart_change_speed) from [<c0231798>] (uart_set_termios+0xa0/0x1fc)
> > [<c0231798>] (uart_set_termios) from [<c022bb44>] (tty_set_termios+0x248/0x2c0)
> > [<c022bb44>] (tty_set_termios) from [<c022c17c>] (set_termios+0x248/0x29c)
> > [<c022c17c>] (set_termios) from [<c022c3e4>] (tty_mode_ioctl+0x1c8/0x4e8)
> > [<c022c3e4>] (tty_mode_ioctl) from [<c0227e70>] (tty_ioctl+0xa94/0xb18)
> > [<c0227e70>] (tty_ioctl) from [<c00cf45c>] (do_vfs_ioctl+0x4a0/0x560)
> > [<c00cf45c>] (do_vfs_ioctl) from [<c00cf568>] (SyS_ioctl+0x4c/0x74)
> > [<c00cf568>] (SyS_ioctl) from [<c000e480>] (ret_fast_syscall+0x0/0x30)
> >
> > Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
> > ---
> > Resend to add stable@vger.kernel.org to CC. As far as I know, this applies to
> > v3.9 and up.
>
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read Documentation/stable_kernel_rules.txt
> for how to do this properly.
>
> </formletter>
>
> I'll take care of this, but go read that file for your next time...
Ah, right. I'll heed that next time. Thanks for taking care of it.
Frans
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-25 10:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20140924080852.GA28215@kroah.com>
2014-09-25 9:19 ` [PATCH resend 1/2] tty: omap-serial: fix division by zero Frans Klaver
2014-09-25 10:16 ` Greg Kroah-Hartman
2014-09-25 10:24 ` Frans Klaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox