Re: [PATCH 1/7] USB: serial: ftdi_sio: Fix divisor overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 7 Jul 2022 17:07:53 +0200
Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:

> On Thu, Jul 07, 2022 at 04:53:48PM +0200, Marek Behún wrote:
> > From: Pali Rohár <pali@xxxxxxxxxx>
> > 
> > Divisor in the register is a 17-bit wide number.
> > Therefore we need to clamp it on overflow.  
> 
> Why, what is wrong with it overflowing, what will happen if it does?

The divisor register is 17-bits wide (14 bits integer part, 3 bits
fractional). So suppose that we compute divisor 0x20001. Writing to
the register puts 0x00001 there, cause the 17th bit gets discarded
(since the register is 17-bits wide). Which will result in dividing by
1.

The best thing we can do if we overflow is put the maximum value to the
divisor, to get the lowest baudrate possible.

> 
> > 
> > Signed-off-by: Pali Rohár <pali@xxxxxxxxxx>
> > Tested-by: Marek Behún <kabel@xxxxxxxxxx>
> > ---
> >  drivers/usb/serial/ftdi_sio.c | 6 ++++++
> >  1 file changed, 6 insertions(+)  
> 
> What commit does this fix?  Is it a bugfix?  Can this ever happen in a
> device?  Should it be backported?.

It is a bugfix; it can happen (happened to Pali when he was trying some
low baudrates); it should be backported.

But it was first introduced in the commit
  1da177e4c3f4 ("Linux-2.6.12-rc2")
which is the very first commit in git :)

Marek




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux