提交 296fa7f6 编写于 作者: W Will Newton 提交者: Linus Torvalds

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: NWill Newton <will.newton@gmail.com>
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 b4dcfbee
...@@ -1795,12 +1795,15 @@ static int __tty_open(struct inode *inode, struct file *filp) ...@@ -1795,12 +1795,15 @@ static int __tty_open(struct inode *inode, struct file *filp)
} }
#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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册