* [PATCH] thermal: cpu_cooling: Use kmalloc_array() in __cpufreq_cooling_register()
@ 2017-04-10 15:12 SF Markus Elfring
2017-04-11 6:10 ` Viresh Kumar
0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-04-10 15:12 UTC (permalink / raw)
To: linux-pm, Amit Daniel Kachhap, Eduardo Valentin, Javi Merino,
Viresh Kumar, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 10 Apr 2017 17:00:13 +0200
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/thermal/cpu_cooling.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 69d0f430b2d1..273d9d5dbe0f 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -823,8 +823,9 @@ __cpufreq_cooling_register(struct device_node *np,
cpufreq_for_each_valid_entry(pos, table)
cpufreq_dev->max_level++;
- cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
- cpufreq_dev->max_level, GFP_KERNEL);
+ cpufreq_dev->freq_table = kmalloc_array(cpufreq_dev->max_level,
+ sizeof(*cpufreq_dev->freq_table),
+ GFP_KERNEL);
if (!cpufreq_dev->freq_table) {
cool_dev = ERR_PTR(-ENOMEM);
goto free_time_in_idle_timestamp;
--
2.12.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] thermal: cpu_cooling: Use kmalloc_array() in __cpufreq_cooling_register()
2017-04-10 15:12 [PATCH] thermal: cpu_cooling: Use kmalloc_array() in __cpufreq_cooling_register() SF Markus Elfring
@ 2017-04-11 6:10 ` Viresh Kumar
0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2017-04-11 6:10 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-pm, Amit Daniel Kachhap, Eduardo Valentin, Javi Merino,
Zhang Rui, LKML, kernel-janitors
On 10-04-17, 17:12, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 10 Apr 2017 17:00:13 +0200
>
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/thermal/cpu_cooling.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 69d0f430b2d1..273d9d5dbe0f 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -823,8 +823,9 @@ __cpufreq_cooling_register(struct device_node *np,
> cpufreq_for_each_valid_entry(pos, table)
> cpufreq_dev->max_level++;
>
> - cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
> - cpufreq_dev->max_level, GFP_KERNEL);
> + cpufreq_dev->freq_table = kmalloc_array(cpufreq_dev->max_level,
> + sizeof(*cpufreq_dev->freq_table),
> + GFP_KERNEL);
> if (!cpufreq_dev->freq_table) {
> cool_dev = ERR_PTR(-ENOMEM);
> goto free_time_in_idle_timestamp;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-11 6:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-10 15:12 [PATCH] thermal: cpu_cooling: Use kmalloc_array() in __cpufreq_cooling_register() SF Markus Elfring
2017-04-11 6:10 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).