From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: PATCH: redo the n_tty fix
Date: Sat, 22 Mar 2003 23:50:47 GMT [thread overview]
Message-ID: <200303222350.h2MNolxF020673@hraefn.swansea.linux.org.uk> (raw)
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
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.5.65-bk3/drivers/char/n_tty.c linux-2.5.65-ac3/drivers/char/n_tty.c
--- linux-2.5.65-bk3/drivers/char/n_tty.c 2003-03-22 19:35:11.000000000 +0000
+++ linux-2.5.65-ac3/drivers/char/n_tty.c 2003-03-22 20:27:06.000000000 +0000
@@ -1029,8 +1029,10 @@
break;
cs = tty->link->ctrl_status;
tty->link->ctrl_status = 0;
- if (put_user(cs, b++)) {
+ if (put_user(cs, b++))
+ {
retval = -EFAULT;
+ b--;
break;
}
nr--;
@@ -1071,8 +1073,9 @@
/* Deal with packet mode. */
if (tty->packet && b == buf) {
- if (put_user(TIOCPKT_DATA, b++)) {
+ if (put_user(TIOCPKT_DATA, b++)) {
retval = -EFAULT;
+ b--;
break;
}
nr--;
@@ -1101,8 +1104,9 @@
spin_unlock_irqrestore(&tty->read_lock, flags);
if (!eol || (c != __DISABLED_CHAR)) {
- if (put_user(c, b++)) {
+ if (put_user(c, b++)) {
retval = -EFAULT;
+ b--;
break;
}
nr--;
@@ -1110,7 +1114,7 @@
if (eol)
break;
}
- if (retval)
+ if (retval)
break;
} else {
int uncopied;
@@ -1146,7 +1150,7 @@
current->state = TASK_RUNNING;
size = b - buf;
- if (!retval && size) {
+ if (size) {
retval = size;
if (nr)
clear_bit(TTY_PUSH, &tty->flags);
next reply other threads:[~2003-03-22 22:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-22 23:50 Alan Cox [this message]
2003-03-23 3:11 ` Linus Torvalds
2003-03-23 15:44 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200303222350.h2MNolxF020673@hraefn.swansea.linux.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®