提交 4b41b953 编写于 作者: P Peter Hurley 提交者: Greg Kroah-Hartman

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: NPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 1e86b5bf
...@@ -1200,10 +1200,8 @@ void tty_write_message(struct tty_struct *tty, char *msg) ...@@ -1200,10 +1200,8 @@ void tty_write_message(struct tty_struct *tty, char *msg)
if (tty) { if (tty) {
mutex_lock(&tty->atomic_write_lock); mutex_lock(&tty->atomic_write_lock);
tty_lock(tty); tty_lock(tty);
if (tty->ops->write && tty->count > 0) { if (tty->ops->write && tty->count > 0)
tty_unlock(tty);
tty->ops->write(tty, msg, strlen(msg)); tty->ops->write(tty, msg, strlen(msg));
} else
tty_unlock(tty); tty_unlock(tty);
tty_write_unlock(tty); tty_write_unlock(tty);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册