Commit 9d0d1f83 authored by Paul Fulghum's avatar Paul Fulghum Committed by Adrian Bunk

tty serialize flush_to_ldisc

Serialize processing of tty buffers in flush_to_ldisc
to fix (very rare) corruption of tty buffer free list
on SMP systems.
Signed-off-by: default avatarPaul Fulghum <paulkf@microgate.com>
Acked-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent 189abe08
...@@ -2759,7 +2759,7 @@ static void flush_to_ldisc(void *private_) ...@@ -2759,7 +2759,7 @@ static void flush_to_ldisc(void *private_)
struct tty_struct *tty = (struct tty_struct *) private_; struct tty_struct *tty = (struct tty_struct *) private_;
unsigned long flags; unsigned long flags;
struct tty_ldisc *disc; struct tty_ldisc *disc;
struct tty_buffer *tbuf; struct tty_buffer *tbuf, *head;
int count; int count;
char *char_buf; char *char_buf;
unsigned char *flag_buf; unsigned char *flag_buf;
...@@ -2776,7 +2776,9 @@ static void flush_to_ldisc(void *private_) ...@@ -2776,7 +2776,9 @@ static void flush_to_ldisc(void *private_)
goto out; goto out;
} }
spin_lock_irqsave(&tty->buf.lock, flags); spin_lock_irqsave(&tty->buf.lock, flags);
while((tbuf = tty->buf.head) != NULL) { head = tty->buf.head;
tty->buf.head = NULL;
while((tbuf = head) != NULL) {
while ((count = tbuf->commit - tbuf->read) != 0) { while ((count = tbuf->commit - tbuf->read) != 0) {
char_buf = tbuf->char_buf_ptr + tbuf->read; char_buf = tbuf->char_buf_ptr + tbuf->read;
flag_buf = tbuf->flag_buf_ptr + tbuf->read; flag_buf = tbuf->flag_buf_ptr + tbuf->read;
...@@ -2785,10 +2787,12 @@ static void flush_to_ldisc(void *private_) ...@@ -2785,10 +2787,12 @@ static void flush_to_ldisc(void *private_)
disc->receive_buf(tty, char_buf, flag_buf, count); disc->receive_buf(tty, char_buf, flag_buf, count);
spin_lock_irqsave(&tty->buf.lock, flags); spin_lock_irqsave(&tty->buf.lock, flags);
} }
if (tbuf->active) if (tbuf->active) {
tty->buf.head = head;
break; break;
tty->buf.head = tbuf->next; }
if (tty->buf.head == NULL) head = tbuf->next;
if (head == NULL)
tty->buf.tail = NULL; tty->buf.tail = NULL;
tty_buffer_free(tty, tbuf); tty_buffer_free(tty, tbuf);
} }
......
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