Skip to content

Commit

Permalink
tty: Fix oops when scanning the polling list for kgdb
Browse files Browse the repository at this point in the history
Costantino Leandro found a bug in tty_find_polling_driver and provided a
patch that fixed the crash but not the underlying bug. This fixes the
underlying bug where the list walk corrupts the values it is using on a
match but then reuses them if the open fails.

Signed-off-by: Alan Cox <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alan Cox authored and torvalds committed Jun 11, 2009
1 parent 620df3c commit 5f0878a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
struct tty_driver *p, *res = NULL;
int tty_line = 0;
int len;
char *str;
char *str, *stp;

for (str = name; *str; str++)
if ((*str >= '0' && *str <= '9') || *str == ',')
Expand All @@ -311,13 +311,14 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
list_for_each_entry(p, &tty_drivers, tty_drivers) {
if (strncmp(name, p->name, len) != 0)
continue;
if (*str == ',')
str++;
if (*str == '\0')
str = NULL;
stp = str;
if (*stp == ',')
stp++;
if (*stp == '\0')
stp = NULL;

if (tty_line >= 0 && tty_line <= p->num && p->ops &&
p->ops->poll_init && !p->ops->poll_init(p, tty_line, str)) {
p->ops->poll_init && !p->ops->poll_init(p, tty_line, stp)) {
res = tty_driver_kref_get(p);
*line = tty_line;
break;
Expand Down

0 comments on commit 5f0878a

Please sign in to comment.