utils/ps: fix inifinite loop in CPU list parser
This commit is contained in:
parent
0d8639ceb8
commit
34bf02d799
|
@ -678,8 +678,8 @@ static void build_cpu_mask(const char *cpu_list)
|
|||
|
||||
s = n = strdup(cpu_list);
|
||||
while ((range = strtok_r(n, ",", &range_p)) != NULL) {
|
||||
if (*range == '\0')
|
||||
continue;
|
||||
if (*range == '\0' || *range == '\n')
|
||||
goto next;
|
||||
end = -1;
|
||||
if (range[strlen(range)-1] == '-')
|
||||
end = nr_cpus - 1;
|
||||
|
@ -704,6 +704,7 @@ static void build_cpu_mask(const char *cpu_list)
|
|||
}
|
||||
for (cpu = start; cpu <= end; cpu++)
|
||||
CPU_SET(cpu, &cpu_restrict);
|
||||
next:
|
||||
n = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue