Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: flush flip buffer on ldisc input queue flush

Flush the tty flip buffer when the line discipline input queue is flushed,
including the user call tcflush(TCIFLUSH/TCIOFLUSH). This prevents
unexpected stale data after a user application calls tcflush().

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Antonino Ingargiola <tritemio@gmail.com>
Signed-off-by: Paul Fulghum <paulkf@microgate.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Paul Fulghum and committed by
Linus Torvalds
c5c34d48 e3bf460f

+33
+33
drivers/char/tty_io.c
··· 369 369 } 370 370 371 371 /** 372 + * tty_buffer_flush - flush full tty buffers 373 + * @tty: tty to flush 374 + * 375 + * flush all the buffers containing receive data 376 + * 377 + * Locking: none 378 + */ 379 + 380 + static void tty_buffer_flush(struct tty_struct *tty) 381 + { 382 + struct tty_buffer *thead; 383 + unsigned long flags; 384 + 385 + spin_lock_irqsave(&tty->buf.lock, flags); 386 + while((thead = tty->buf.head) != NULL) { 387 + tty->buf.head = thead->next; 388 + tty_buffer_free(tty, thead); 389 + } 390 + tty->buf.tail = NULL; 391 + spin_unlock_irqrestore(&tty->buf.lock, flags); 392 + } 393 + 394 + /** 372 395 * tty_buffer_find - find a free tty buffer 373 396 * @tty: tty owning the buffer 374 397 * @size: characters wanted ··· 1271 1248 ld->flush_buffer(tty); 1272 1249 tty_ldisc_deref(ld); 1273 1250 } 1251 + tty_buffer_flush(tty); 1274 1252 } 1275 1253 1276 1254 EXPORT_SYMBOL_GPL(tty_ldisc_flush); ··· 3374 3350 case TIOCMBIC: 3375 3351 case TIOCMBIS: 3376 3352 return tty_tiocmset(tty, file, cmd, p); 3353 + case TCFLSH: 3354 + switch (arg) { 3355 + case TCIFLUSH: 3356 + case TCIOFLUSH: 3357 + /* flush tty buffer and allow ldisc to process ioctl */ 3358 + tty_buffer_flush(tty); 3359 + break; 3360 + } 3361 + break; 3377 3362 } 3378 3363 if (tty->driver->ioctl) { 3379 3364 retval = (tty->driver->ioctl)(tty, file, cmd, arg);