]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/tty/n_tty.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
[mirror_ubuntu-bionic-kernel.git] / drivers / tty / n_tty.c
index d15624c1b75161877e6319e6460981866feb54cb..fe9d129c87351b47392320a626dedb89e2f0bf55 100644 (file)
@@ -1900,13 +1900,10 @@ static inline int input_available_p(struct tty_struct *tty, int poll)
        struct n_tty_data *ldata = tty->disc_data;
        int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1;
 
-       if (ldata->icanon && !L_EXTPROC(tty)) {
-               if (ldata->canon_head != ldata->read_tail)
-                       return 1;
-       } else if (read_cnt(ldata) >= amt)
-               return 1;
-
-       return 0;
+       if (ldata->icanon && !L_EXTPROC(tty))
+               return ldata->canon_head != ldata->read_tail;
+       else
+               return read_cnt(ldata) >= amt;
 }
 
 /**
@@ -2356,8 +2353,12 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
                        if (tty->ops->flush_chars)
                                tty->ops->flush_chars(tty);
                } else {
+                       struct n_tty_data *ldata = tty->disc_data;
+
                        while (nr > 0) {
+                               mutex_lock(&ldata->output_lock);
                                c = tty->ops->write(tty, b, nr);
+                               mutex_unlock(&ldata->output_lock);
                                if (c < 0) {
                                        retval = c;
                                        goto break_out;