diff options
Diffstat (limited to 'drivers/char/hvc_console.c')
-rw-r--r-- | drivers/char/hvc_console.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index de849f571ea2..7bc65a76dfc4 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -192,12 +192,21 @@ void hvc_console_print(struct console *co, const char *b, unsigned count) | |||
192 | 192 | ||
193 | static struct tty_driver *hvc_console_device(struct console *c, int *index) | 193 | static struct tty_driver *hvc_console_device(struct console *c, int *index) |
194 | { | 194 | { |
195 | if (vtermnos[c->index] == -1) | ||
196 | return NULL; | ||
197 | |||
195 | *index = c->index; | 198 | *index = c->index; |
196 | return hvc_driver; | 199 | return hvc_driver; |
197 | } | 200 | } |
198 | 201 | ||
199 | static int __init hvc_console_setup(struct console *co, char *options) | 202 | static int __init hvc_console_setup(struct console *co, char *options) |
200 | { | 203 | { |
204 | if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES) | ||
205 | return -ENODEV; | ||
206 | |||
207 | if (vtermnos[co->index] == -1) | ||
208 | return -ENODEV; | ||
209 | |||
201 | return 0; | 210 | return 0; |
202 | } | 211 | } |
203 | 212 | ||
@@ -227,12 +236,21 @@ console_initcall(hvc_console_init); | |||
227 | */ | 236 | */ |
228 | int hvc_instantiate(uint32_t vtermno, int index) | 237 | int hvc_instantiate(uint32_t vtermno, int index) |
229 | { | 238 | { |
239 | struct hvc_struct *hp; | ||
240 | |||
230 | if (index < 0 || index >= MAX_NR_HVC_CONSOLES) | 241 | if (index < 0 || index >= MAX_NR_HVC_CONSOLES) |
231 | return -1; | 242 | return -1; |
232 | 243 | ||
233 | if (vtermnos[index] != -1) | 244 | if (vtermnos[index] != -1) |
234 | return -1; | 245 | return -1; |
235 | 246 | ||
247 | /* make sure no no tty has been registerd in this index */ | ||
248 | hp = hvc_get_by_index(index); | ||
249 | if (hp) { | ||
250 | kobject_put(&hp->kobj); | ||
251 | return -1; | ||
252 | } | ||
253 | |||
236 | vtermnos[index] = vtermno; | 254 | vtermnos[index] = vtermno; |
237 | 255 | ||
238 | /* reserve all indices upto and including this index */ | 256 | /* reserve all indices upto and including this index */ |