summaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2015-10-11 02:28:44 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-18 06:30:49 +0200
commit4b41b9539a1e9531f942ededfcdcff372317d2e7 (patch)
treec32d3b6fd91a8a8af7d498400c6ef3fcd73c7496 /drivers/tty/tty_io.c
parenttty: core: Use correct spinlock flavor in tiocspgrp() (diff)
downloadlinux-4b41b9539a1e9531f942ededfcdcff372317d2e7.tar.xz
linux-4b41b9539a1e9531f942ededfcdcff372317d2e7.zip
tty: Prevent tty teardown during tty_write_message()
tty_write_message() allows the caller to directly write to a specific tty. Since the line discipline is bypassed for the direct write, nothing prevents the tty from being torn down after the tty count is checked. Hold the tty lock for the duration of the direct write. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to '')
-rw-r--r--drivers/tty/tty_io.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 071671a8674f..173fdeba0987 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1200,11 +1200,9 @@ void tty_write_message(struct tty_struct *tty, char *msg)
if (tty) {
mutex_lock(&tty->atomic_write_lock);
tty_lock(tty);
- if (tty->ops->write && tty->count > 0) {
- tty_unlock(tty);
+ if (tty->ops->write && tty->count > 0)
tty->ops->write(tty, msg, strlen(msg));
- } else
- tty_unlock(tty);
+ tty_unlock(tty);
tty_write_unlock(tty);
}
return;