aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavi Merino <javi.merino@arm.com>2015-03-20 18:20:13 +0000
committerKevin Hilman <khilman@linaro.org>2015-09-08 09:22:39 -0700
commitdf2c5365a9d741659cc5d8c83181f8b9b418b458 (patch)
treefa8834abda170e725d1077021558013c66fdba2e
parent1144afc25044c3db57f6756296788659bfe6b9d5 (diff)
downloadlinux-linaro-stable-df2c5365a9d741659cc5d8c83181f8b9b418b458.tar.gz
thermal: cpu_cooling: Check memory allocation of power_table
We allocate the power_table in memory but we don't test whether the allocation succeeded. Return -ENOMEM if kcalloc() fails. Fixes: e0128d8ab423 ("thermal: cpu_cooling: implement the power cooling device API") Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Zhang Rui <rui.zhang@intel.com> Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com> (cherry picked from commit 0cdf97e1ad8d796313de051528f06c1b16f3a679) Signed-off-by: Kevin Hilman <khilman@linaro.org>
-rw-r--r--drivers/thermal/cpu_cooling.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 07a9629..6509c61 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -289,6 +289,10 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
}
power_table = kcalloc(num_opps, sizeof(*power_table), GFP_KERNEL);
+ if (!power_table) {
+ ret = -ENOMEM;
+ goto unlock;
+ }
for (freq = 0, i = 0;
opp = dev_pm_opp_find_freq_ceil(dev, &freq), !IS_ERR(opp);