cpufreq: governor: Avoid accessing invalid governor_data
authorHenry Willard <henry.willard@oracle.com>
Wed, 15 Aug 2018 00:01:02 +0000 (17:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Sep 2018 17:55:58 +0000 (19:55 +0200)
commit924383edf44c2a4190820853c6e33c0deb24d98a
tree85d800455ff4b40fcb3e69b4073891224727b037
parent256f63f52ec3fc0aa3a62d4c8f710ea39b7b7fdc
cpufreq: governor: Avoid accessing invalid governor_data

commit 2a3eb51e30b9ac66fe1b75877627a7e4aaeca24a upstream.

If cppc_cpufreq.ko is deleted at the same time that tuned-adm is
changing profiles, there is a small chance that a race can occur
between cpufreq_dbs_governor_exit() and cpufreq_dbs_governor_limits()
resulting in a system failure when the latter tries to use
policy->governor_data that has been freed by the former.

This patch uses gov_dbs_data_mutex to synchronize access.

Fixes: e788892ba3cc (cpufreq: governor: Get rid of governor events)
Signed-off-by: Henry Willard <henry.willard@oracle.com>
[ rjw: Subject, minor white space adjustment ]
Cc: 4.8+ <stable@vger.kernel.org> # 4.8+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/cpufreq/cpufreq_governor.c