Messages in this thread Patch in this message | | | From | Yizhuo <> | Subject | [PATCH] kernel/smp: Variable nr_cpus is uninitialized if get_option() returns 0 | Date | Thu, 29 Aug 2019 17:29:50 -0700 |
| |
Inside function nrcpus(), variable nr_cpus is uninitialized if get_option() returns 0. However, the value will be used in the if statement, which is potentially unsafe.
Signed-off-by: Yizhuo <yzhai003@ucr.edu> --- kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/smp.c b/kernel/smp.c index c94dd85c8d41..4bf24d4dc041 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -527,7 +527,7 @@ early_param("nosmp", nosmp); /* this is hard limit */ static int __init nrcpus(char *str) { - int nr_cpus; + int nr_cpus = 0; get_option(&str, &nr_cpus); if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) -- 2.17.1
| |