summaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorgaurav jindal <gauravjindal1104@gmail.com>2018-01-05 14:01:30 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-01-05 14:01:30 +0100
commit3cfd68b5ba8737d28bfcf9b6487ea4d9216b8504 (patch)
treecf579ba6621e0b44c11f2a8afaa9138d56caa6ec /drivers/cpuidle
parentLinux 4.15-rc6 (diff)
downloadlinux-3cfd68b5ba8737d28bfcf9b6487ea4d9216b8504.tar.xz
linux-3cfd68b5ba8737d28bfcf9b6487ea4d9216b8504.zip
cpuidle: Avoid NULL argument in cpuidle_switch_governor()
Checks if the new governor is NULL before updating the cupidle_curr_governor. Signed-off-by: gaurav jindal <gauravjindal1104@gmail.com> [ rjw : Subject ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/governor.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
index 4e78263e34a4..5d359aff3cc5 100644
--- a/drivers/cpuidle/governor.c
+++ b/drivers/cpuidle/governor.c
@@ -36,14 +36,15 @@ static struct cpuidle_governor * __cpuidle_find_governor(const char *str)
/**
* cpuidle_switch_governor - changes the governor
* @gov: the new target governor
- *
- * NOTE: "gov" can be NULL to specify disabled
* Must be called with cpuidle_lock acquired.
*/
int cpuidle_switch_governor(struct cpuidle_governor *gov)
{
struct cpuidle_device *dev;
+ if (!gov)
+ return -EINVAL;
+
if (gov == cpuidle_curr_governor)
return 0;