tty: WARN for attempted set_termios() of pty master
[firefly-linux-kernel-4.4.55.git] / drivers / tty / tty_ioctl.c
index 62380ccf70fb469f3e3c676452819ecfdf6ff4b5..ab4562c06af413a1dc26d85ad26542b0267b6a85 100644 (file)
@@ -528,6 +528,8 @@ EXPORT_SYMBOL(tty_termios_hw_change);
  *     is a bit of layering violation here with n_tty in terms of the
  *     internal knowledge of this function.
  *
+ *     A master pty's termios should never be set.
+ *
  *     Locking: termios_rwsem
  */
 
@@ -537,6 +539,8 @@ int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
        struct tty_ldisc *ld;
        unsigned long flags;
 
+       WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+               tty->driver->subtype == PTY_TYPE_MASTER);
        /*
         *      Perform the actual termios internal changes under lock.
         */