[PATCH 1/2] drivers/char/tty_io.c: Avoid panic when no console isconfigured.

From: Alan Cox
Date: Mon Dec 01 2008 - 06:36:18 EST


From: \"Will Newton\" <will.newton@xxxxxxxxx>

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@xxxxxxxxx>
Signed-off-by: Alan Cox <alan@xxxxxxxxxx>
---

drivers/char/tty_io.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)


diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 966be86..ac73fd9 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1793,12 +1793,15 @@ retry_open:
}
#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;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/