From patchwork Tue Feb 7 04:10:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 93506 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2023777qgi; Mon, 6 Feb 2017 20:10:26 -0800 (PST) X-Received: by 10.84.128.66 with SMTP id 60mr23007265pla.34.1486440626736; Mon, 06 Feb 2017 20:10:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p23si2780932pfl.37.2017.02.06.20.10.26; Mon, 06 Feb 2017 20:10:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752857AbdBGEKS (ORCPT + 13 others); Mon, 6 Feb 2017 23:10:18 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:33822 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752783AbdBGEKR (ORCPT ); Mon, 6 Feb 2017 23:10:17 -0500 Received: by mail-pg0-f42.google.com with SMTP id 14so34617122pgg.1 for ; Mon, 06 Feb 2017 20:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=aybvzCQyF/cl91snLaCrbSGDv0kHhE29TwS3nsX2V78=; b=bMA/E4niZxVZ4Cu9+nCKDbAnu+Qby74niHWn26jBuN5ppCSVG1gCZ7JUR5P1cgFUwk r9E1ikJF4cIJKqMvavee1zeHYQneuJA9DtqF2kFqn8lZXyAlxZcS8XN4vHoguJO/BPck bYup/chbn6BSh+HVvr/kIldmukX2uCfzaLMEo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=aybvzCQyF/cl91snLaCrbSGDv0kHhE29TwS3nsX2V78=; b=Zt3U4ZAUdikDfluVEQJT44ncEil7pDRlhjA8oORu746u7mS1s+VvMwb/Fm0Ak5EPsI Em7NtfhuCY/JCOpFPz5MYsmdBctmRMJLPl3ezxsoDZYjpVB2cDWwZ3Tu/dqRwTYa0tUR v/PHbAKmhjAxRX0j3VDNqEnCceTCj+aapBV8NZaQZWvm02ncKYII5fUbDD26AJrJBIzz Lum2fuaPyzhKdmp+6R69k6KXxAIju4nQRHVK/dAQ3mJChCcFK65Jf4MfbRGOWOeCliJO 4Xx1KFBxvf+M9QKjcw6Bx7FcuN9CxKkiu3wgJYf1GA4Idj32A31QpF1VskCCg+drnQ83 HcLQ== X-Gm-Message-State: AIkVDXLvUOJYg82LbEa0cGbTlGCVkCIDKuygUlCWGYGS8bQEbrBNHQ2s1OlwFYXUPexFMjwu X-Received: by 10.99.245.21 with SMTP id w21mr17553746pgh.117.1486440616834; Mon, 06 Feb 2017 20:10:16 -0800 (PST) Received: from localhost ([122.172.165.189]) by smtp.gmail.com with ESMTPSA id u29sm6302304pfl.17.2017.02.06.20.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 20:10:16 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , rui.zhang@intel.com, edubezval@gmail.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , dan.carpenter@oracle.com, Viresh Kumar Subject: [PATCH V2 3/5] thermal: devfreq: Check OPP for errors Date: Tue, 7 Feb 2017 09:40:03 +0530 Message-Id: <06c4a7a43d537bf078f6ac72187853e11bd0384e.1486440448.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: <79611a51240c83504c35a8739fe8e1837e903671.1486440448.git.viresh.kumar@linaro.org> References: <79611a51240c83504c35a8739fe8e1837e903671.1486440448.git.viresh.kumar@linaro.org> In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org It is possible for dev_pm_opp_find_freq_exact() to return errors. It was all fine earlier as dev_pm_opp_get_voltage() had a check within it to check for invalid OPPs, but dev_pm_opp_put() doesn't have any similar checks and the callers need to make sure OPP is valid before calling them. Also update the later dev_warn_ratelimited() to not print the error message as the OPP is guaranteed to be valid now. Reported-by: Dan Carpenter Signed-off-by: Viresh Kumar --- drivers/thermal/devfreq_cooling.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.7.1.410.g6faf27b -- 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/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index 218ccc30c7ad..74d4846c66cd 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -225,13 +225,19 @@ get_static_power(struct devfreq_cooling_device *dfc, unsigned long freq) if (PTR_ERR(opp) == -ERANGE) opp = dev_pm_opp_find_freq_exact(dev, freq, false); + if (IS_ERR(opp)) { + dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n", + freq, PTR_ERR(opp)); + return 0; + } + voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */ dev_pm_opp_put(opp); if (voltage == 0) { dev_err_ratelimited(dev, - "Failed to get voltage for frequency %lu: %ld\n", - freq, IS_ERR(opp) ? PTR_ERR(opp) : 0); + "Failed to get voltage for frequency %lu\n", + freq); return 0; } From patchwork Tue Feb 7 04:10:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 93508 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2023820qgi; Mon, 6 Feb 2017 20:10:37 -0800 (PST) X-Received: by 10.99.101.199 with SMTP id z190mr17312233pgb.219.1486440636952; Mon, 06 Feb 2017 20:10:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t15si2744305pgn.358.2017.02.06.20.10.36; Mon, 06 Feb 2017 20:10:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752956AbdBGEKa (ORCPT + 13 others); Mon, 6 Feb 2017 23:10:30 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36312 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752913AbdBGEK3 (ORCPT ); Mon, 6 Feb 2017 23:10:29 -0500 Received: by mail-pf0-f181.google.com with SMTP id 189so29435045pfu.3 for ; Mon, 06 Feb 2017 20:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=gIYfIMN6jvcAmAuvYvFGsbnk047cU43i7Tf96LVy978=; b=SWpg22hoCeoQ9wsqUE1UycnGChevHWKn8q86AC9KybOPWT2zXBFuEM8J7r03pAixuB VoRo3oT4pxX6u1a5jMsqVC85Xpvswl+su/woaKgs5hF//Jwe5GAMWSgGHtBaYfyZMwNI xVMGmMt0aDNb8qn5oLQ+KTOY/GGH0woSXP7HQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=gIYfIMN6jvcAmAuvYvFGsbnk047cU43i7Tf96LVy978=; b=LWUSkBG1qbqPfAX5AufGmn0TiWAp02he53EPuOitmHstTArtdGrOizfklWwcmzCTKw +h8V2w2trEOLD//FDn4eMLwPliWlq5yHJK0BZ99NVCV2wx7j8cVXeahWQ8YNOe6bMC3V k5T6HI2DFXjR8M5NefWQ5/xcTMpuHJq4xVoPolUwAK/ovC5Y4rCLN0N59TKTEIEWrcqc B10eOb2ElPyOIOrnrDCCMrUe9+VbGyh10DqMXbDzCNs5NVpFPKNCKSh1XzLz6whj3pQ7 oGYziD6a/FD6souAvl4yJO8AbxH2653DEZ9E6InXiKHG2bD6vb76s9by6gYutI9F+mei w4RA== X-Gm-Message-State: AMke39l81113UhGjsw+hKCjFW3qFcQSsgHhbPICkZUXKjSF491Wi/zX4/xpX3tm7E/+t4cFI X-Received: by 10.84.248.65 with SMTP id e1mr823642pln.117.1486440623467; Mon, 06 Feb 2017 20:10:23 -0800 (PST) Received: from localhost ([122.172.165.189]) by smtp.gmail.com with ESMTPSA id k78sm6120378pfb.93.2017.02.06.20.10.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 20:10:22 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , rui.zhang@intel.com, edubezval@gmail.com, Amit Daniel Kachhap , Viresh Kumar , Javi Merino Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , dan.carpenter@oracle.com Subject: [PATCH V2 5/5] thermal: cpu_cooling: Check OPP for errors Date: Tue, 7 Feb 2017 09:40:05 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: <79611a51240c83504c35a8739fe8e1837e903671.1486440448.git.viresh.kumar@linaro.org> References: <79611a51240c83504c35a8739fe8e1837e903671.1486440448.git.viresh.kumar@linaro.org> In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org It is possible for dev_pm_opp_find_freq_exact() to return errors. It was all fine earlier as dev_pm_opp_get_voltage() had a check within it to check for invalid OPPs, but dev_pm_opp_put() doesn't have any similar checks and the callers need to make sure OPP is valid before calling them. Also update the later dev_warn_ratelimited() to not print the error message as the OPP is guaranteed to be valid now. Reported-by: Dan Carpenter Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.7.1.410.g6faf27b -- 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 caaaeb3ac0f0..30d736289b87 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -431,13 +431,20 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_device, opp = dev_pm_opp_find_freq_exact(cpufreq_device->cpu_dev, freq_hz, true); + if (IS_ERR(opp)) { + dev_warn_ratelimited(cpufreq_device->cpu_dev, + "Failed to find OPP for frequency %lu: %ld\n", + freq_hz, PTR_ERR(opp)); + return -EINVAL; + } + voltage = dev_pm_opp_get_voltage(opp); dev_pm_opp_put(opp); if (voltage == 0) { dev_err_ratelimited(cpufreq_device->cpu_dev, - "Failed to get voltage for frequency %lu: %ld\n", - freq_hz, IS_ERR(opp) ? PTR_ERR(opp) : 0); + "Failed to get voltage for frequency %lu\n", + freq_hz); return -EINVAL; }