提交 5f0878ac 编写于 作者: A Alan Cox 提交者: Linus Torvalds

tty: Fix oops when scanning the polling list for kgdb

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: NAlan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 620df3c0
...@@ -295,7 +295,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) ...@@ -295,7 +295,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
struct tty_driver *p, *res = NULL; struct tty_driver *p, *res = NULL;
int tty_line = 0; int tty_line = 0;
int len; int len;
char *str; char *str, *stp;
for (str = name; *str; str++) for (str = name; *str; str++)
if ((*str >= '0' && *str <= '9') || *str == ',') if ((*str >= '0' && *str <= '9') || *str == ',')
...@@ -311,13 +311,14 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) ...@@ -311,13 +311,14 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
list_for_each_entry(p, &tty_drivers, tty_drivers) { list_for_each_entry(p, &tty_drivers, tty_drivers) {
if (strncmp(name, p->name, len) != 0) if (strncmp(name, p->name, len) != 0)
continue; continue;
if (*str == ',') stp = str;
str++; if (*stp == ',')
if (*str == '\0') stp++;
str = NULL; if (*stp == '\0')
stp = NULL;
if (tty_line >= 0 && tty_line <= p->num && p->ops && 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); res = tty_driver_kref_get(p);
*line = tty_line; *line = tty_line;
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册