From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753085AbbEDOCm (ORCPT ); Mon, 4 May 2015 10:02:42 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:34744 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbbEDOCe (ORCPT ); Mon, 4 May 2015 10:02:34 -0400 Message-ID: <55477BF7.2020102@linaro.org> Date: Mon, 04 May 2015 16:02:31 +0200 From: Daniel Lezcano User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: "Rafael J. Wysocki" , Peter Zijlstra CC: Linux PM list , Linux Kernel Mailing List Subject: Re: [PATCH 2/4] cpuidle: Check the sign of index in cpuidle_reflect() References: <3084951.QaIkFrZ3VU@vostro.rjw.lan> <1452615.qnuzHTbuFj@vostro.rjw.lan> In-Reply-To: <1452615.qnuzHTbuFj@vostro.rjw.lan> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/04/2015 03:57 PM, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Avoid calling the governor's ->reflect method if the state index > passed to cpuidle_reflect() is negative. > > This allows the analogous check to be dropped from menu_reflect(), > so do that too, and ensures that arbitrary error codes can be > passed to cpuidle_reflect() as the index with no adverse > consequences. > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Daniel Lezcano > --- > drivers/cpuidle/cpuidle.c | 2 +- > drivers/cpuidle/governors/menu.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > Index: linux-pm/drivers/cpuidle/cpuidle.c > =================================================================== > --- linux-pm.orig/drivers/cpuidle/cpuidle.c > +++ linux-pm/drivers/cpuidle/cpuidle.c > @@ -249,7 +249,7 @@ int cpuidle_enter(struct cpuidle_driver > */ > void cpuidle_reflect(struct cpuidle_device *dev, int index) > { > - if (cpuidle_curr_governor->reflect) > + if (cpuidle_curr_governor->reflect && index >= 0) > cpuidle_curr_governor->reflect(dev, index); > } > > Index: linux-pm/drivers/cpuidle/governors/menu.c > =================================================================== > --- linux-pm.orig/drivers/cpuidle/governors/menu.c > +++ linux-pm/drivers/cpuidle/governors/menu.c > @@ -367,9 +367,9 @@ static int menu_select(struct cpuidle_dr > static void menu_reflect(struct cpuidle_device *dev, int index) > { > struct menu_device *data = this_cpu_ptr(&menu_devices); > + > data->last_state_idx = index; > - if (index >= 0) > - data->needs_update = 1; > + data->needs_update = 1; > } > > /** > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog