cpuidle: Avoid NULL argument in cpuidle_switch_governor()
authorgaurav jindal <gauravjindal1104@gmail.com>
Fri, 5 Jan 2018 13:01:30 +0000 (14:01 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 5 Jan 2018 13:01:30 +0000 (14:01 +0100)
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>
drivers/cpuidle/governor.c

index 4e78263e34a476c2280b5c317cd054bc5d3e6c86..5d359aff3cc538005f6ebeb3b32a2ded2dd5605b 100644 (file)
@@ -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;