Skip to content

Commit ac89a91

Browse files
committed
pty: don't limit the writes to 'pty_space()' inside 'pty_write()'
The whole write-room thing is something that is up to the _caller_ to worry about, not the pty layer itself. The total buffer space will still be limited by the buffering routines themselves, so there is no advantage or need in having pty_write() artificially limit the size somehow. And what happened was that the caller (the n_tty line discipline, in this case) may have verified that there is room for 2 bytes to be written (for NL -> CRNL expansion), and it used to then do those writes as two single-byte writes. And if the first byte written (CR) then caused a new tty buffer to be allocated, pty_space() may have returned zero when trying to write the second byte (LF), and then incorrectly failed the write - leading to a lost newline character. This should finally fix http://bugzilla.kernel.org/show_bug.cgi?id=14015 Reported-by: Mikael Pettersson <mikpe@it.uu.se> Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 37f81fa commit ac89a91

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

drivers/char/pty.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,13 @@ static int pty_space(struct tty_struct *to)
109109
* the other side of the pty/tty pair.
110110
*/
111111

112-
static int pty_write(struct tty_struct *tty, const unsigned char *buf,
113-
int count)
112+
static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
114113
{
115114
struct tty_struct *to = tty->link;
116-
int c;
117115

118116
if (tty->stopped)
119117
return 0;
120118

121-
/* This isn't locked but our 8K is quite sloppy so no
122-
big deal */
123-
124-
c = pty_space(to);
125-
if (c > count)
126-
c = count;
127119
if (c > 0) {
128120
/* Stuff the data into the input queue of the other end */
129121
c = tty_insert_flip_string(to, buf, c);

0 commit comments

Comments
 (0)