From ed31919f2ae06910f38769fa3b5c0911bb30832f Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Thu, 7 Jul 2005 17:56:23 -0700 Subject: [PATCH] --- yaml --- r: 4229 b: refs/heads/master c: 7805b1b29ffdd252dfef36aa28d7bda70cd586d3 h: refs/heads/master i: 4227: ac13c87566e0d2c0b0a963a057115939bc2ca53f v: v3 --- [refs] | 2 +- trunk/drivers/char/hvc_console.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index d0ec6ad1ce46..d2abbf4328d1 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 64e4da57964c03da9a03087a398cade81b7bb496 +refs/heads/master: 7805b1b29ffdd252dfef36aa28d7bda70cd586d3 diff --git a/trunk/drivers/char/hvc_console.c b/trunk/drivers/char/hvc_console.c index de849f571ea2..7bc65a76dfc4 100644 --- a/trunk/drivers/char/hvc_console.c +++ b/trunk/drivers/char/hvc_console.c @@ -192,12 +192,21 @@ void hvc_console_print(struct console *co, const char *b, unsigned count) static struct tty_driver *hvc_console_device(struct console *c, int *index) { + if (vtermnos[c->index] == -1) + return NULL; + *index = c->index; return hvc_driver; } static int __init hvc_console_setup(struct console *co, char *options) { + if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES) + return -ENODEV; + + if (vtermnos[co->index] == -1) + return -ENODEV; + return 0; } @@ -227,12 +236,21 @@ console_initcall(hvc_console_init); */ int hvc_instantiate(uint32_t vtermno, int index) { + struct hvc_struct *hp; + if (index < 0 || index >= MAX_NR_HVC_CONSOLES) return -1; if (vtermnos[index] != -1) return -1; + /* make sure no no tty has been registerd in this index */ + hp = hvc_get_by_index(index); + if (hp) { + kobject_put(&hp->kobj); + return -1; + } + vtermnos[index] = vtermno; /* reserve all indices upto and including this index */