Commit 58934356 authored by Muchun Song's avatar Muchun Song Committed by Peter Zijlstra

smp: Fix a potential usage of stale nr_cpus

The get_option() maybe return 0, it means that the nr_cpus is
not initialized. Then we will use the stale nr_cpus to initialize
the nr_cpu_ids. So fix it.
Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200716070457.53255-1-songmuchun@bytedance.com
parent 3edecfef
...@@ -634,8 +634,7 @@ static int __init nrcpus(char *str) ...@@ -634,8 +634,7 @@ static int __init nrcpus(char *str)
{ {
int nr_cpus; int nr_cpus;
get_option(&str, &nr_cpus); if (get_option(&str, &nr_cpus) && nr_cpus > 0 && nr_cpus < nr_cpu_ids)
if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
nr_cpu_ids = nr_cpus; nr_cpu_ids = nr_cpus;
return 0; return 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