Skip to contentSkip to conversation

goldfish: off by one in goldfish_tty_console_setup()

PATCH New Dan Carpenter 1 participant 1 message Oct 29, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 goldfish: off by one in goldfish_tty_console_setup()

The goldfish_ttys[] array has "goldfish_tty_line_count" number of elements. It's allocated in goldfish_tty_create_driver(). This test should be >= instead of >.

drivers/tty/goldfish.c +1 -1
index 09495f5..2f68540 100644
@@ -155,7 +155,7 @@ static struct tty_driver *goldfish_tty_console_device(struct console *c,
 
 static int goldfish_tty_console_setup(struct console *co, char *options)
 {
-	if ((unsigned)co->index > goldfish_tty_line_count)
+	if ((unsigned)co->index >= goldfish_tty_line_count)
 		return -ENODEV;
 	if (goldfish_ttys[co->index].base = 0)
 		return -ENODEV;