Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b41b953 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

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: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1e86b5bf
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1200,10 +1200,8 @@ 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_write_unlock(tty);
	}