lkml.org 
[lkml]   [2019]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] kernel/smp: Variable nr_cpus is uninitialized if get_option() returns 0
Date
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
\
 
 \ /
  Last update: 2019-08-30 02:30    [W:0.114 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site