diff mbox series

cpufreq: ap806: Add NULL check after kcalloc

Message ID 20190721180815.GA12437@hari-Inspiron-1545 (mailing list archive)
State Mainlined
Commit 3355c91b79394593ebbb197c8e930a91826f4ff3
Headers show
Series cpufreq: ap806: Add NULL check after kcalloc | expand

Commit Message

Hariprasad Kelam July 21, 2019, 6:08 p.m. UTC
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

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
---
 drivers/cpufreq/armada-8k-cpufreq.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Viresh Kumar July 22, 2019, 5:43 a.m. UTC | #1
On 21-07-19, 23:38, Hariprasad Kelam wrote:
> 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
> 
> Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
> ---
>  drivers/cpufreq/armada-8k-cpufreq.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/cpufreq/armada-8k-cpufreq.c b/drivers/cpufreq/armada-8k-cpufreq.c
> index 988ebc3..39e34f50 100644
> --- a/drivers/cpufreq/armada-8k-cpufreq.c
> +++ b/drivers/cpufreq/armada-8k-cpufreq.c
> @@ -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.
diff mbox series

Patch

diff --git a/drivers/cpufreq/armada-8k-cpufreq.c b/drivers/cpufreq/armada-8k-cpufreq.c
index 988ebc3..39e34f50 100644
--- a/drivers/cpufreq/armada-8k-cpufreq.c
+++ b/drivers/cpufreq/armada-8k-cpufreq.c
@@ -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);
 
 	/*