Skip to contentSkip to conversation

cpufreq: ap806: Add NULL check after kcalloc

PATCH Applied Hariprasad Kelam 2 participants 2 messages Jul 21, 2019 – Jul 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: ap806: Add NULL check after kcalloc

Add NULL check after kcalloc.

Fix below issue reported by coccicheck ./drivers/cpufreq/armada-8k-cpufreq.c:138:1-12: alloc with no test, possible model on line 151

---
 drivers/cpufreq/armada-8k-cpufreq.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/cpufreq/armada-8k-cpufreq.c +2 -0
index 988ebc3..39e34f50 100644
@@ -136,6 +136,8 @@ static int __init armada_8k_cpufreq_init(void)
 
 	nb_cpus = num_possible_cpus();
 	freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);
+	if (!freq_tables)
+		return -ENOMEM;
 	cpumask_copy(&cpus, cpu_possible_mask);
 
 	/*
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 16 lines · Hariprasad Kelam

Add NULL check after kcalloc.

Fix below issue reported by coccicheck ./drivers/cpufreq/armada-8k-cpufreq.c:138:1-12: alloc with no test, possible model on line 151

---
 drivers/cpufreq/armada-8k-cpufreq.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/cpufreq/armada-8k-cpufreq.c +0 -0
index 988ebc3..39e34f50 100644

drivers/cpufreq/armada-8k-cpufreq.c static int __init armada_8k_cpufreq_init(void) · line 143

Quoted 8 lines
drivers/cpufreq/armada-8k-cpufreq.c +2 -0
@@ -136,6 +136,8 @@ static int __init armada_8k_cpufreq_init(void)
 
 	nb_cpus = num_possible_cpus();
 	freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);
+	if (!freq_tables)
+		return -ENOMEM;
 	cpumask_copy(&cpus, cpu_possible_mask);
 
 	/*

Applied. Thanks.

Signature · 1 line
viresh