summaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/devfreq.c
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2021-09-29 06:42:45 +0200
committerChanwoo Choi <cw00.choi@samsung.com>2021-10-27 07:22:12 +0200
commit5cf79c293821d12fd88dee901692cd404247782e (patch)
tree9286f02a87eeca28f1b7e819125fa43b30e8f5ce /drivers/devfreq/devfreq.c
parentdevfreq: exynos-ppmu: simplify parsing event-type from DT (diff)
downloadlinux-5cf79c293821d12fd88dee901692cd404247782e.tar.xz
linux-5cf79c293821d12fd88dee901692cd404247782e.zip
PM / devfreq: Strengthen check for freq_table
Since commit ea572f816032 ("PM / devfreq: Change return type of devfreq_set_freq_table()"), all devfreq devices are expected to have a valid freq_table. The devfreq core unconditionally dereferences freq_table in the sysfs code and in get_freq_range(). Therefore, we need to ensure that freq_table is both non-null and non-empty (length is > 0). If either check fails, replace the table using set_freq_table() or return the error. Signed-off-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r--drivers/devfreq/devfreq.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 85faa7a5c7d1..06333d430382 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -827,7 +827,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
goto err_dev;
}
- if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {
+ if (!devfreq->profile->max_state || !devfreq->profile->freq_table) {
mutex_unlock(&devfreq->lock);
err = set_freq_table(devfreq);
if (err < 0)