Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Samuel Holland and committed by
Chanwoo Choi
5cf79c29 14714135

+1 -1
+1 -1
drivers/devfreq/devfreq.c
··· 827 827 goto err_dev; 828 828 } 829 829 830 - if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { 830 + if (!devfreq->profile->max_state || !devfreq->profile->freq_table) { 831 831 mutex_unlock(&devfreq->lock); 832 832 err = set_freq_table(devfreq); 833 833 if (err < 0)