[PATCH 5/5] tty: fix tty_line must not be equal to number of allocated tty pointers in tty driver

Date

Fri, 3 Sep 2010 19:13:22 -0700

From: Nathael Pajani <nathael.pajani@ed3l.fr>

I found a bug "by chance" in drivers/char/tty_io.c

I mean "by chance" because I was just reading the code of thetty_find_polling_driver() to make a new tty_find_by_name() function.

In tty_find_polling_driver() the driver actually test "tty_line <=p->num" while num refers to the number of struct tty_struct pointersallocated for the p->ttys (p is a tty_driver), and tty_line is scannedin a tty name, which can be for example ttyS2. Then tty_line equals 2.And if p->num is 2, we have only p->ttys[0] and p->ttys[1], but nop->ttys[2].

This is actually unharmful, for tty_find_polling_driver() is used onlyin drivers/serial/kgdboc.c, and there's a test over there to find aconsole with a matching index, which will never happen.