From patchwork Wed Dec 3 05:10:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 41834 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A49D725E66 for ; Wed, 3 Dec 2014 05:10:20 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id n15sf8971457lbi.4 for ; Tue, 02 Dec 2014 21:10:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=mjYIzJ2nDHP6n9ySC7una7iB+1XL1NlcU74GYLxAing=; b=IXJBUS1SAkhHmFqlKOYl2gVCS+26B91pX+t9NOXkq0Pe4R/h/IkaRgWf1Hf9Or+sgQ BQ0nd0tI03lioXRsgogxoAghA9TXc8pRezQRvq6R29r5GPu+8HTa6gOp6olZ+jhRlvID xvZRr0amiKAwB4k9FrThQXpe+3W3B6SKb3F56Nv5CjIIB+ZGqDOeZP4Spq0KNmtaaEiz o7dXg1Et7a1h5JvzkwfxRI7WIGiiI13pTi6QMFoX6Vs3m9Qb8hUL+XDRk8/7LSpq9aA4 +52ywA9NwPsO0/F/Ubud2dm1Sfma794sXfkLjMyoWTC8Xmu1v9RdHe79sGgA/ybcFfCi ycxw== X-Gm-Message-State: ALoCoQkDFCNs6opF8zEwuxGcG32BAGskZBXTtvKtVQxE6Vxt0KmM8dG6v26MZuuDEejP2qQnKyfy X-Received: by 10.180.8.9 with SMTP id n9mr1665127wia.6.1417583419260; Tue, 02 Dec 2014 21:10:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.134 with SMTP id t6ls97726lag.78.gmail; Tue, 02 Dec 2014 21:10:18 -0800 (PST) X-Received: by 10.152.23.9 with SMTP id i9mr2396758laf.81.1417583418974; Tue, 02 Dec 2014 21:10:18 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id w6si22032258lad.65.2014.12.02.21.10.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 21:10:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so11466332lab.8 for ; Tue, 02 Dec 2014 21:10:18 -0800 (PST) X-Received: by 10.112.38.4 with SMTP id c4mr2525204lbk.46.1417583418855; Tue, 02 Dec 2014 21:10:18 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp611750lbc; Tue, 2 Dec 2014 21:10:17 -0800 (PST) X-Received: by 10.70.55.102 with SMTP id r6mr5070964pdp.55.1417583416456; Tue, 02 Dec 2014 21:10:16 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ji4si22526527pbb.42.2014.12.02.21.10.14 for ; Tue, 02 Dec 2014 21:10:16 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750862AbaLCFKM (ORCPT + 12 others); Wed, 3 Dec 2014 00:10:12 -0500 Received: from mail-oi0-f53.google.com ([209.85.218.53]:51245 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbaLCFKM (ORCPT ); Wed, 3 Dec 2014 00:10:12 -0500 Received: by mail-oi0-f53.google.com with SMTP id x69so10404393oia.12 for ; Tue, 02 Dec 2014 21:10:11 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.182.245.231 with SMTP id xr7mr1916937obc.78.1417583411310; Tue, 02 Dec 2014 21:10:11 -0800 (PST) Received: by 10.182.56.162 with HTTP; Tue, 2 Dec 2014 21:10:11 -0800 (PST) In-Reply-To: <20141202233626.GA3969@developer> References: <8c0412592bfd5524e638252a42edaf08f81f0976.1417167599.git.viresh.kumar@linaro.org> <20141202233626.GA3969@developer> Date: Wed, 3 Dec 2014 10:40:11 +0530 Message-ID: Subject: Re: [PATCH 25/26] cpu_cooling: Use cpufreq_dev->freq_table for finding level/freq From: Viresh Kumar To: Eduardo Valentin Cc: "linux-pm@vger.kernel.org" , Lists linaro-kernel , Zhang Rui Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 3 December 2014 at 05:06, Eduardo Valentin wrote: >> - ret = get_property(cpufreq_device, state, &clip_freq, GET_FREQ); >> - if (ret) >> - return ret; >> - >> + clip_freq = cpufreq_device->freq_table[state]; > > There should be some check for valid state here.. What about this ?? return 0; --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 6bd95bc..6e76417 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -228,6 +228,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus); unsigned int clip_freq; + /* Request state should be less than max_level */ + if (WARN_ON(state > cpufreq_device->max_level)) + return -EINVAL; + /* Check if the old cooling action is same as new cooling action */ if (cpufreq_device->cpufreq_state == state)