lkml.org 
[lkml]   [2020]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v3] smp: Fix a potential usage of stale nr_cpus
Date
Ingo Molnar <mingo@kernel.org> writes:
>> - get_option(&str, &nr_cpus);
>> + if (get_option(&str, &nr_cpus) != 1)
>> + return -EINVAL;
>> +
>> if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
>> nr_cpu_ids = nr_cpus;
>> + else
>> + return -EINVAL;
>
> Exactly what does 'not valid' mean, and why doesn't get_option()
> return -EINVAL in that case?

What's unclear about invalid? If you specify nr_cpus=-1 or
nr_cpus=2000000 the its obviously invalid.

How should get_option() know that this is invalid? get_option() is a
number parser and does not know about any restrictions on the parsed
value obviously.

get_option() returns string parsing information:

0 -> not integer found
1 -> integer found, no trailing comma or hyphen
2 -> integer found and trailing comma
3 -> integer found and traling hyphen (range parsing)

And that's what is checked in if (get_option() != 1), i.e. anything else
than a plain integer is invalid for this command line option.

Thanks,

tglx


\
 
 \ /
  Last update: 2020-07-27 18:05    [W:0.042 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site