diff options
author | Muchun Song <songmuchun@bytedance.com> | 2020-07-16 09:04:57 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2020-07-22 10:22:04 +0200 |
commit | 589343569d7b58a64ec2446e6686c8e79aea7fcf (patch) | |
tree | 9315aba02d65fa567e540488cc2973dd8d06e66b /kernel/smp.c | |
parent | sched/fair: update_pick_idlest() Select group with lowest group_util when idl... (diff) | |
download | linux-589343569d7b58a64ec2446e6686c8e79aea7fcf.tar.xz linux-589343569d7b58a64ec2446e6686c8e79aea7fcf.zip |
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: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200716070457.53255-1-songmuchun@bytedance.com
Diffstat (limited to 'kernel/smp.c')
-rw-r--r-- | kernel/smp.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/smp.c b/kernel/smp.c index aa17eedff5be..d0ae8eb6bf8b 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -634,8 +634,7 @@ static int __init nrcpus(char *str) { int nr_cpus; - get_option(&str, &nr_cpus); - if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) + if (get_option(&str, &nr_cpus) && nr_cpus > 0 && nr_cpus < nr_cpu_ids) nr_cpu_ids = nr_cpus; return 0; |