Skip to content

Commit

Permalink
n_tty: Protect minimum_to_wake reset for concurrent readers
Browse files Browse the repository at this point in the history
With multiple, concurrent readers (each waiting to acquire the
atomic_read_lock mutex), a departing reader may mistakenly reset
minimum_to_wake after a new reader has already set a new value.

Protect the minimum_to_wake reset with the atomic_read_lock critical
section.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Nov 25, 2013
1 parent d4855e1 commit aebf045
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,12 +2249,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
n_tty_set_room(tty);
up_read(&tty->termios_rwsem);

mutex_unlock(&ldata->atomic_read_lock);
remove_wait_queue(&tty->read_wait, &wait);

if (!waitqueue_active(&tty->read_wait))
ldata->minimum_to_wake = minimum;

mutex_unlock(&ldata->atomic_read_lock);

__set_current_state(TASK_RUNNING);
if (b - buf)
retval = b - buf;
Expand Down

0 comments on commit aebf045

Please sign in to comment.