diff options
-rw-r--r-- | drivers/char/tty_io.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 1eda82b31a61..eb8b5be4e249 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -312,7 +312,7 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size) | |||
312 | 312 | ||
313 | int tty_buffer_request_room(struct tty_struct *tty, size_t size) | 313 | int tty_buffer_request_room(struct tty_struct *tty, size_t size) |
314 | { | 314 | { |
315 | struct tty_buffer *b = tty->buf.head, *n; | 315 | struct tty_buffer *b = tty->buf.tail, *n; |
316 | int left = 0; | 316 | int left = 0; |
317 | 317 | ||
318 | /* OPTIMISATION: We could keep a per tty "zero" sized buffer to | 318 | /* OPTIMISATION: We could keep a per tty "zero" sized buffer to |
@@ -326,7 +326,6 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size) | |||
326 | n = tty_buffer_find(tty, size); | 326 | n = tty_buffer_find(tty, size); |
327 | if(n == NULL) | 327 | if(n == NULL) |
328 | return left; | 328 | return left; |
329 | n->next = b; | ||
330 | if(b != NULL) | 329 | if(b != NULL) |
331 | b->next = n; | 330 | b->next = n; |
332 | else | 331 | else |
@@ -2751,6 +2750,8 @@ static void flush_to_ldisc(void *private_) | |||
2751 | spin_lock_irqsave(&tty->read_lock, flags); | 2750 | spin_lock_irqsave(&tty->read_lock, flags); |
2752 | while((tbuf = tty->buf.head) != NULL) { | 2751 | while((tbuf = tty->buf.head) != NULL) { |
2753 | tty->buf.head = tbuf->next; | 2752 | tty->buf.head = tbuf->next; |
2753 | if (tty->buf.head == NULL) | ||
2754 | tty->buf.tail = NULL; | ||
2754 | spin_unlock_irqrestore(&tty->read_lock, flags); | 2755 | spin_unlock_irqrestore(&tty->read_lock, flags); |
2755 | /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */ | 2756 | /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */ |
2756 | disc->receive_buf(tty, tbuf->char_buf_ptr, | 2757 | disc->receive_buf(tty, tbuf->char_buf_ptr, |
@@ -2759,7 +2760,6 @@ static void flush_to_ldisc(void *private_) | |||
2759 | spin_lock_irqsave(&tty->read_lock, flags); | 2760 | spin_lock_irqsave(&tty->read_lock, flags); |
2760 | tty_buffer_free(tty, tbuf); | 2761 | tty_buffer_free(tty, tbuf); |
2761 | } | 2762 | } |
2762 | tty->buf.tail = NULL; | ||
2763 | spin_unlock_irqrestore(&tty->read_lock, flags); | 2763 | spin_unlock_irqrestore(&tty->read_lock, flags); |
2764 | out: | 2764 | out: |
2765 | tty_ldisc_deref(disc); | 2765 | tty_ldisc_deref(disc); |