lkml.org 
[lkml]   [2008]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH] 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>
---
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 59f4721..1412a8d 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1795,12 +1795,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;
--
1.5.5.2From 52399d4ddbe920874009cf4dff80a8b08b071167 Mon Sep 17 00:00:00 2001
From: Will Newton <will.newton@gmail.com>
Date: Thu, 20 Nov 2008 14:19:05 +0000
Subject: [PATCH] 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>
---
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 59f4721..1412a8d 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1795,12 +1795,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;
--
1.5.5.2
\
 
 \ /
  Last update: 2008-11-20 16:05    [W:0.029 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site