mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* PATCH: redo the n_tty fix
@ 2003-03-22 23:50 Alan Cox
  2003-03-23  3:11 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2003-03-22 23:50 UTC (permalink / raw)
  To: linux-kernel, torvalds


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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: redo the n_tty fix
  2003-03-22 23:50 PATCH: redo the n_tty fix Alan Cox
@ 2003-03-23  3:11 ` Linus Torvalds
  2003-03-23 15:44   ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2003-03-23  3:11 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel


On Sat, 22 Mar 2003, Alan Cox wrote:
> 
> I think this way of doing it is right but it could do with further
> review

Alan, please stop doing whitespace changes that are WRONG.

> -			if (put_user(cs, b++)) {
> +			if (put_user(cs, b++))
> +			{

This is uglier and against the kernel coding style.

		Linus


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: redo the n_tty fix
  2003-03-23  3:11 ` Linus Torvalds
@ 2003-03-23 15:44   ` Alan Cox
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Cox @ 2003-03-23 15:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux Kernel Mailing List

On Sun, 2003-03-23 at 03:11, Linus Torvalds wrote:
> On Sat, 22 Mar 2003, Alan Cox wrote:
> > 
> > I think this way of doing it is right but it could do with further
> > review
> 
> Alan, please stop doing whitespace changes that are WRONG.

If you stopped merging broken patches I wouldn't have to redo them ;)

I missed that one when fixing the other stuff up to Torvalds style.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-23 14:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-22 23:50 PATCH: redo the n_tty fix Alan Cox
2003-03-23  3:11 ` Linus Torvalds
2003-03-23 15:44   ` Alan Cox

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®