From patchwork Mon Mar 13 10:07:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95198 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp1101050qgd; Mon, 13 Mar 2017 03:09:00 -0700 (PDT) X-Received: by 10.84.129.2 with SMTP id 2mr46480849plb.119.1489399740298; Mon, 13 Mar 2017 03:09:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w27si10992632pgc.348.2017.03.13.03.09.00; Mon, 13 Mar 2017 03:09:00 -0700 (PDT) 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=pass 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752140AbdCMKIc (ORCPT + 13 others); Mon, 13 Mar 2017 06:08:32 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:36493 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbdCMKIX (ORCPT ); Mon, 13 Mar 2017 06:08:23 -0400 Received: by mail-pg0-f48.google.com with SMTP id g2so44682644pge.3 for ; Mon, 13 Mar 2017 03:08:22 -0700 (PDT) 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=VGo8/N7RVEzA8GbE2yl4iJZb/iPvd/l2RN8qCGLVSFw=; b=NXRHRZc+3C0LLKmTvbjNQFwe6csVMo+xDIgi6O6jda8pMYS3eaTVEoH1xGFtwDfZ8F zD4XvwTBzq1In4szFJ3IOuLvrJ5dxDrJJc+cQ20+Sa8QQgHYY9Ncd5BOndECK+iGOkXK I1+wyeKUTJHJJyCyuM478afjTuL5HeOIqTKZ0= 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=VGo8/N7RVEzA8GbE2yl4iJZb/iPvd/l2RN8qCGLVSFw=; b=U/tLP5wORiYIT9zQR5rGyTpMvgb0FoCf0g6AgfECf30Uq0MLbxftK5/7HkBAmamgZA 0Oz1ALq0icFC0svegwoDchKGFANapcwM05DYrTlj+3YVOqYqxxL5TXz0/uPmPPKhUQ3i u93eegzwPu2BUBy2IgrwWLMfDvN8tbx/H+hSIsdPuWy48OkTkxLi/noMXRqu0/B7SxkH OupjhDaBaqc1kF10NzNOaNMQ/aI8pvz5MlPmmOeioJ20HMLz+4EFUpmkSx5QcExCJfHB xkUMPZZMOmwwTlMqgogXxN0zl9U1z7DtjgpF4koWKCqEiR6/RNQ8cFtHHMr91Gf2CbiW RBWA== X-Gm-Message-State: AMke39mg3sj+5aapYh/rlDaIR+TOrUMpd3QbpgXzHpaqbahMHBsU9LxPLygRm4B9LIPHRnt3 X-Received: by 10.98.2.21 with SMTP id 21mr36318700pfc.93.1489399701701; Mon, 13 Mar 2017 03:08:21 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id q64sm32410281pga.0.2017.03.13.03.08.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 03:08:21 -0700 (PDT) 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 V3 3/5] thermal: devfreq: Check OPP for errors Date: Mon, 13 Mar 2017 15:37:36 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: 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 Acked-by: Zhang Rui --- drivers/thermal/devfreq_cooling.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index e99d0e026a53..4bf4ad58cffd 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -189,13 +189,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; }