diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-11-07 23:01:57 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-25 21:17:49 +0400 |
commit | aebf045382edb32bd763d8edea02a559e7dc41e9 (patch) | |
tree | eeba9a7cacf8a5a14500af01eaf626839655a480 /drivers/tty | |
parent | d4855e1fc03c2bb32dd64badf51cec5a2a26ab2a (diff) | |
download | linux-aebf045382edb32bd763d8edea02a559e7dc41e9.tar.xz |
n_tty: Protect minimum_to_wake reset for concurrent readers
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>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/n_tty.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index c222a561c5ac..0f74945af624 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -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; |