Skip to content

Commit 5cf79c2

Browse files
smaeulchanwoochoi
authored andcommitted
PM / devfreq: Strengthen check for freq_table
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 <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 1471413 commit 5cf79c2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/devfreq/devfreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
827827
goto err_dev;
828828
}
829829

830-
if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {
830+
if (!devfreq->profile->max_state || !devfreq->profile->freq_table) {
831831
mutex_unlock(&devfreq->lock);
832832
err = set_freq_table(devfreq);
833833
if (err < 0)

0 commit comments

Comments
 (0)