[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190830002950.22458-1-yzhai003@ucr.edu>
Date:   Thu, 29 Aug 2019 17:29:50 -0700
From:   Yizhuo <yzhai003@....edu>
To:     unlisted-recipients:; (no To-header on input)
Cc:     csong@...ucr.edu, zhiyunq@...ucr.edu, Yizhuo <yzhai003@....edu>,
        linux-kernel@...r.kernel.org
Subject: [PATCH] kernel/smp: Variable nr_cpus is uninitialized if get_option() returns 0
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@....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
Powered by blists - more mailing lists
 
