Commit f7371879 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] redo the n_tty fix

Two problems with the original change

1. We should return bytes actually processed on an error according to
SuS/POSIX. Technically the EFAULT path is outside the spec but its best
we follow

2. We need to fix most of this anyway because the final section of the
change was wrong. If retval was set we retried and got an efault again
in some cases

I think this way of doing it is right but it could do with further
review
parent fca86803
......@@ -1031,6 +1031,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
tty->link->ctrl_status = 0;
if (put_user(cs, b++)) {
retval = -EFAULT;
b--;
break;
}
nr--;
......@@ -1073,6 +1074,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
if (tty->packet && b == buf) {
if (put_user(TIOCPKT_DATA, b++)) {
retval = -EFAULT;
b--;
break;
}
nr--;
......@@ -1103,6 +1105,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
if (!eol || (c != __DISABLED_CHAR)) {
if (put_user(c, b++)) {
retval = -EFAULT;
b--;
break;
}
nr--;
......@@ -1146,7 +1149,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
current->state = TASK_RUNNING;
size = b - buf;
if (!retval && size) {
if (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