lkml.org 
[lkml]   [2017]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH]cpuidle: preventive check in cpuidle_select against crash
On Wed, Dec 27, 2017 at 01:42:58AM +0100, Rafael J. Wysocki wrote:
> On Tue, Dec 26, 2017 at 8:26 AM, gaurav jindal
> <gauravjindal1104@gmail.com> wrote:
> > When selecting the idle state using cpuidle_select, there is no
> > check on cpuidle_curr_governor. In cpuidle_switch_governor,
> > cpuidle_currr_governor can be set to NULL to specify "disabled".
>
> How exactly?

In cpuidle_switch_governor:

/**
* 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 == cpuidle_curr_governor)
return 0;

cpuidle_uninstall_idle_handler();

if (cpuidle_curr_governor) {
list_for_each_entry(dev, &cpuidle_detected_devices, device_list)
cpuidle_disable_device(dev);
}

cpuidle_curr_governor = gov;

This allows to set the cpuidle_switch_governor as NULL. Although there is no
current code flow leading here, but it has a potential for bug in future. So
may be better to have prevention.

\
 
 \ /
  Last update: 2017-12-27 02:57    [W:0.077 / U:0.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site