[PATCH] Handle the old_termios == 0 case e.g. uart_resume_port()

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

 



  Handle null old_termios in ftdi_set_termios() calls from uart_resume_port().

Signed-off-by: Andrew Worsley <amworsley@xxxxxxxxx>

---

  Much thanks to Dan Carpenter for pointing this issue out, although my
  testing didn't trigger the issue, I think it's much better to avoid it.

  For people interested in reproducing this issue I have some more details.
  It doesn't really make sense to me but for the record here it is.

  Examing the strace -v output we have bash generating several ioctl()s on
  each typing of the command line which was the test that produced the issue
  on an intermittent basis - say 1 out 3-5 attempts:

      uname -a

  of which the following might be most relevant:

  The only changes I can see are:

      c_iflags 0400 = -ICRNL
      c_lflags 02 = -ICANON, 010  = -ECHO
  
  Perhaps this is causing the fairly empty ftdi_set_termios() calls?
  ioctl() calls:

ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {
    c_iflags=0x1500, c_oflags=0x5, c_cflags=0x1cb2, c_lflags=0xa3b, c_line=0,
    c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
    = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {
    c_iflags=0x1500, c_oflags=0x5, c_cflags=0x1cb2, c_lflags=0xa3b, c_line=0,
    c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})
    = 0
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {
    c_iflags=0x1400, c_oflags=0x5, c_cflags=0x1cb2, c_lflags=0xa31, c_line=0,
    c_cc[VMIN]=1, c_cc[VTIME]=0,
    c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x00\x00\x00\x00"})
    = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {
    c_iflags=0x1400, c_oflags=0x5, c_cflags=0x1cb2, c_lflags=0xa31, c_line=0,
    c_cc[VMIN]=1, c_cc[VTIME]=0,
    c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x00\x00\x00\x00"})
    = 0

> bash --version
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)

 drivers/usb/serial/ftdi_sio.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index bd4298b..13e4ecc 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2104,6 +2104,9 @@ static void ftdi_set_termios(struct tty_struct *tty,
 
 	cflag = termios->c_cflag;
 
+	if (old_termios == 0)
+		goto no_skip;
+
 	if (old_termios->c_cflag == termios->c_cflag
 	    && old_termios->c_ispeed == termios->c_ispeed
 	    && old_termios->c_ospeed == termios->c_ospeed)
@@ -2117,6 +2120,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
 	    (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)))
 		goto no_data_parity_stop_changes;
 
+no_skip:
 	/* Set number of data bits, parity, stop bits */
 
 	urb_value = 0;
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux