diff options
| author | gaurav jindal <gauravjindal1104@gmail.com> | 2017-09-08 00:07:43 +0530 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2017-09-14 18:24:20 +0200 |
| commit | 3927d76c2da12e5353580ae22c664d4c5c6959a0 (patch) | |
| tree | 6a055f3973bddac2ea00cb8a5f4e1668473e5dba | |
| parent | d808b73c6007df3f6fc3a72b8144b6028c7d6dfb (diff) | |
drivers: cpufreq: checks to avoid kernel crash in cpufreq_interactive
In cpufreq_governor_interactive, driver throws warning with WARN_ON
for !tunables and event != CPUFREQ_GOV_POLICY_INIT.
In case when tunables is NULL for event other than
CPUFREQ_GOV_POLICY_INIT, kernel will crash as there is no safe check
available before accessing tunables. So to handle such case and avoid
the kernel crash, return -EINVAL if WARN_ON returns TRUE.
Change-Id: I7a3a22d58e3c8a315a1cc1d31143649dc8807dee
Signed-off-by: gaurav jindal <gauravjindal1104@gmail.com>
| -rw-r--r-- | drivers/cpufreq/cpufreq_interactive.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 4556b7c44..019b6dd64 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -1142,7 +1142,8 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, else tunables = common_tunables; - WARN_ON(!tunables && (event != CPUFREQ_GOV_POLICY_INIT)); + if (WARN_ON(!tunables && (event != CPUFREQ_GOV_POLICY_INIT))) + return -EINVAL; switch (event) { case CPUFREQ_GOV_POLICY_INIT: |
