From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751642AbdL0B52 (ORCPT ); Tue, 26 Dec 2017 20:57:28 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46809 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278AbdL0B50 (ORCPT ); Tue, 26 Dec 2017 20:57:26 -0500 X-Google-Smtp-Source: ACJfBotS1e2V5kTtXpn/aNpb/EImg2ZUhNzfpBBPZ6LtudR1fPgfbH93tbYTpG6XDg1xIYrN+sE3EA== Date: Wed, 27 Dec 2017 07:27:22 +0530 From: gaurav jindal To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Daniel Lezcano , Linux PM , Linux Kernel Mailing List Subject: Re: [PATCH]cpuidle: preventive check in cpuidle_select against crash Message-ID: <20171227015722.GA3413@gaurav.jindal> References: <20171226072626.GA4153@gaurav.jindal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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.