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: Will Newton <will.newton@gmail.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Will Newton 2008-12-01 11:36:06 +00:00 committed by Linus Torvalds
parent b4dcfbee3b
commit 296fa7f6a3

View File

@ -1795,12 +1795,15 @@ retry_open:
} }
#endif #endif
if (device == MKDEV(TTYAUX_MAJOR, 1)) { if (device == MKDEV(TTYAUX_MAJOR, 1)) {
driver = tty_driver_kref_get(console_device(&index)); struct tty_driver *console_driver = console_device(&index);
if (driver) { if (console_driver) {
/* Don't let /dev/console block */ driver = tty_driver_kref_get(console_driver);
filp->f_flags |= O_NONBLOCK; if (driver) {
noctty = 1; /* Don't let /dev/console block */
goto got_driver; filp->f_flags |= O_NONBLOCK;
noctty = 1;
goto got_driver;
}
} }
mutex_unlock(&tty_mutex); mutex_unlock(&tty_mutex);
return -ENODEV; return -ENODEV;