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; }