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

Commit 296fa7f6 authored by Will Newton's avatar Will Newton Committed by Linus Torvalds
Browse files

drivers/char/tty_io.c: Avoid panic when no console is configured.



When no console is configured tty_open tries to call kref_get on a NULL
pointer, return ENODEV instead.

Signed-off-by: default avatarWill Newton <will.newton@gmail.com>
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b4dcfbee
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -1795,13 +1795,16 @@ retry_open:
	}
#endif
	if (device == MKDEV(TTYAUX_MAJOR, 1)) {
		driver = tty_driver_kref_get(console_device(&index));
		struct tty_driver *console_driver = console_device(&index);
		if (console_driver) {
			driver = tty_driver_kref_get(console_driver);
			if (driver) {
				/* Don't let /dev/console block */
				filp->f_flags |= O_NONBLOCK;
				noctty = 1;
				goto got_driver;
			}
		}
		mutex_unlock(&tty_mutex);
		return -ENODEV;
	}