Commit 0dca0fd2 authored by Jason Wessel's avatar Jason Wessel

kgdboc,tty: Fix tty polling search to use name correctly

The tty_find_polling_driver() routine did not correctly check the base
part of the tty name.  This can lead to kgdboc selecting an incorrect
driver, as well as accepting a completely invalid tty such as "echo
ffff0 > /sys/module/kgdboc/parameters/kgdboc".
Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
parent 703a1edc
...@@ -695,13 +695,23 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) ...@@ -695,13 +695,23 @@ 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;
char *str; char *str;
for (str = name; *str; str++)
if ((*str >= '0' && *str <= '9') || *str == ',')
break;
if (!*str)
return NULL;
len = str - name;
tty_line = simple_strtoul(str, &str, 10);
mutex_lock(&tty_mutex); mutex_lock(&tty_mutex);
/* Search through the tty devices to look for a match */ /* Search through the tty devices to look for a match */
list_for_each_entry(p, &tty_drivers, tty_drivers) { list_for_each_entry(p, &tty_drivers, tty_drivers) {
str = name + strlen(p->name); if (strncmp(name, p->name, len) != 0)
tty_line = simple_strtoul(str, &str, 10); continue;
if (*str == ',') if (*str == ',')
str++; str++;
if (*str == '\0') if (*str == '\0')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment