thermal: cpu_cooling: Replace kmalloc with kmalloc_array
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 23 May 2017 07:03:06 +0000 (12:33 +0530)
committerEduardo Valentin <edubezval@gmail.com>
Sun, 28 May 2017 00:33:04 +0000 (17:33 -0700)
Checkpatch reports following:

WARNING: Prefer kmalloc_array over kmalloc with multiply
+ cpufreq_cdev->freq_table = kmalloc(sizeof(*cpufreq_cdev->freq_table) * i,

Fix that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/cpu_cooling.c

index 1305020790b2809ea9d078b4e50511b19d2dda2a..908a8014cf767efb34f4b8dfe6b4958738fa2d84 100644 (file)
@@ -724,8 +724,9 @@ __cpufreq_cooling_register(struct device_node *np,
        /* max_level is an index, not a counter */
        cpufreq_cdev->max_level = i - 1;
 
-       cpufreq_cdev->freq_table = kmalloc(sizeof(*cpufreq_cdev->freq_table) * i,
-                                         GFP_KERNEL);
+       cpufreq_cdev->freq_table = kmalloc_array(i,
+                                       sizeof(*cpufreq_cdev->freq_table),
+                                       GFP_KERNEL);
        if (!cpufreq_cdev->freq_table) {
                cdev = ERR_PTR(-ENOMEM);
                goto free_idle_time;