Skip to content

Commit

Permalink
drivers/char/tty_io.c: Avoid panic when no console is configured.
Browse files Browse the repository at this point in the history
When no console is configured tty_open tries to call kref_get on a NULL
pointer, return ENODEV instead.

Signed-off-by: Will Newton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
willnewton authored and torvalds committed Dec 1, 2008
1 parent b4dcfbe commit 296fa7f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1795,12 +1795,15 @@ static int __tty_open(struct inode *inode, struct file *filp)
}
#endif
if (device == MKDEV(TTYAUX_MAJOR, 1)) {
driver = tty_driver_kref_get(console_device(&index));
if (driver) {
/* Don't let /dev/console block */
filp->f_flags |= O_NONBLOCK;
noctty = 1;
goto got_driver;
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;
Expand Down

0 comments on commit 296fa7f

Please sign in to comment.