Skip to content

Commit

Permalink
PM / devfreq: Strengthen check for freq_table
Browse files Browse the repository at this point in the history
Since commit ea572f8 ("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>
  • Loading branch information
Samuel Holland authored and Chanwoo Choi committed Oct 27, 2021
1 parent 1471413 commit 5cf79c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5cf79c2

Please sign in to comment.