Skip to contentSkip to conversation

Series short description

PATCH New Alan Cox 1 participant 3 messages Dec 1, 2008

Subsystems (3)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

cover Series short description

A pair of small fixes for nasty console related bugs from the various tty merges and updates.

Alan

author
#1 lore raw

PATCH 1/2 drivers/char/tty_io.c: Avoid panic when no console is configured.

From: \"Will Newton\" <[email protected]>

When no console is configured tty_open tries to call kref_get on a NULL pointer, return ENODEV instead.

---

 drivers/char/tty_io.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
drivers/char/tty_io.c +9 -6
index 966be86..ac73fd9 100644
@@ -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;
author
#2 lore raw

PATCH 2/2 Add kref to fake tty used by USB console

In reply to Alan Cox

From: Kevin Hao <[email protected]>

We alloc a fake tty in usb serial console setup function. we should init the tty's kref otherwise we will face WARN_ON after following invoke of tty_port_tty_set --> tty_kref_get.

---

 drivers/usb/serial/console.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/usb/serial/console.c +1 -0
index 5b20de1..5b95009 100644
@@ -135,6 +135,7 @@ static int usb_console_setup(struct console *co, char *options)
 				err("no more memory");
 				goto reset_open_count;
 			}
+			kref_init(&tty->kref);
 			termios = kzalloc(sizeof(*termios), GFP_KERNEL);
 			if (!termios) {
 				retval = -ENOMEM;