Re: [PATCH 2/2] sc16is7xx: Fix wrong tx fifo level read-out by preventing empty writes

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

 



On Monday, November 09, 2015 10:04:03 PM Jakub Kiciński wrote:
> 
> Florian,

Jakub, thank you for your patience with me. Of course you are right. I was to 
blind to see it, when I split my original change in two parts.

> 
> if we apply both of your patches the flow will be like this:
> 
> 1.  txlen = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG);
> 2.  if (txlen > SC16IS7XX_FIFO_SIZE) {
> 3.          dev_err(...);
> 4.          txlen = 0;

Here we drop an impossible input value.

> 5.  }
> 6.  to_send = (to_send > txlen) ? txlen : to_send;
> 7.  /* Prevent ... */
> 8.  to_send = (to_send > SC16IS7XX_FIFO_SIZE) ?
> 9.             SC16IS7XX_FIFO_SIZE : to_send;

And this was intended to prevent the overrun itself.
 
> If we replace '= 0' on line 4 with = SC16IS7XX_FIFO_SIZE, this
> code can be rewritten as:
> 
> 1.  txlen = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG);
> 2.  txlen   = min(txlen, SC16IS7XX_FIFO_SIZE);
> 3.  to_send = min(txlen, to_send);
> 4.  to_send = min(to_send, SC16IS7XX_FIFO_SIZE);
> 
> Can you see now why I claim that your first patch is unnecessary?
> It's enough to make sure txlen is not larger than FIFO, since to_send
> cannot be larger than txlen it will never be larger than FIFO as well.

Yes, I can see now, thank you and sorry for my blindness.
What do we do? Pick only 2/2?

Sorry for causing so much work,
Florian
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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