Commit eb0e2cf6 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add missing put_user checks in n_tty

From: Steven Rostedt <rostedt@goodmis.org>

The n_tty driver is missing some put_user checks.
parent e7b90940
......@@ -1029,7 +1029,10 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
break;
cs = tty->link->ctrl_status;
tty->link->ctrl_status = 0;
put_user(cs, b++);
if (put_user(cs, b++)) {
retval = -EFAULT;
break;
}
nr--;
break;
}
......@@ -1068,7 +1071,10 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
/* Deal with packet mode. */
if (tty->packet && b == buf) {
put_user(TIOCPKT_DATA, b++);
if (put_user(TIOCPKT_DATA, b++)) {
retval = -EFAULT;
break;
}
nr--;
}
......@@ -1095,12 +1101,17 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
spin_unlock_irqrestore(&tty->read_lock, flags);
if (!eol || (c != __DISABLED_CHAR)) {
put_user(c, b++);
if (put_user(c, b++)) {
retval = -EFAULT;
break;
}
nr--;
}
if (eol)
break;
}
if (retval)
break;
} else {
int uncopied;
uncopied = copy_from_read_buf(tty, &b, &nr);
......@@ -1135,7 +1146,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
current->state = TASK_RUNNING;
size = b - buf;
if (size) {
if (!retval && size) {
retval = size;
if (nr)
clear_bit(TTY_PUSH, &tty->flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment