Re: [PATCH v9 4/6] serial: take termios_rwsem for ->rs485_config() & pass termios as param

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

 



On 24. 06. 22, 22:42, Ilpo Järvinen wrote:
To be able to alter ADDRB within ->rs485_config(), take termios_rwsem
before calling ->rs485_config() and pass termios.

OK, FTR, worth noting the tty->termios_rwsem -> port->mutex lock chain is preexisting.

Anyway, I'm not sure I buy the above. Why is termios_rwsem needed to alter ADDRB?

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 621fc15e2e54..44c3785445e3 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
...
@@ -1511,6 +1511,10 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
  	if (ret != -ENOIOCTLCMD)
  		goto out;
+ /* rs485_config requires more locking than others */
+	if (cmd == TIOCGRS485)
+		down_write(&tty->termios_rwsem);
+
  	mutex_lock(&port->mutex);
  	uport = uart_port_check(state);
...
@@ -1551,6 +1555,8 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
  	}
  out_up:
  	mutex_unlock(&port->mutex);
+	if (cmd == TIOCGRS485)
+		up_write(&tty->termios_rwsem);
  out:
  	return ret;
  }

thanks,
--
js



[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