From patchwork Mon Feb 6 10:26:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 93396 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1644091qgi; Mon, 6 Feb 2017 02:27:06 -0800 (PST) X-Received: by 10.99.36.7 with SMTP id k7mr12483381pgk.201.1486376826320; Mon, 06 Feb 2017 02:27:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si300718plq.10.2017.02.06.02.27.05; Mon, 06 Feb 2017 02:27:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1751715AbdBFK07 (ORCPT + 25 others); Mon, 6 Feb 2017 05:26:59 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:36655 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574AbdBFK0w (ORCPT ); Mon, 6 Feb 2017 05:26:52 -0500 Received: by mail-pf0-f180.google.com with SMTP id 189so23250022pfu.3 for ; Mon, 06 Feb 2017 02:26:52 -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=ivgz9RHZCreyGp7b5fLMZTQx71Ow0nf7fPFdmtccQPM=; b=ab7DF1jo+OJuMg595X6nJEnXhBB7wKlbgzcvRtJIAgbL00IZN0XAN3ddiLf8Pk6ouv MB6Xlw/61fxLg9ICkTNtszVUia7UuHCJhXbhNBd3nmSOqwG4Jggz4+XStvt3B8B/hCWc nNa1bScO+mNf6ZZYQwy0eqYATHdpjT/YoVoHo= 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=ivgz9RHZCreyGp7b5fLMZTQx71Ow0nf7fPFdmtccQPM=; b=Wh9ePKUsJ3E/uEGJk68CRUPv+0IbHzrTHXM4WR/J1GMFxhhZDIOtRfjcsUolPbkwFa nDYiJL+Yh7s34pOiSiIOrT+Ldn+PKRjAH29A+4z61L6PPl9JsO6mbK/vEPRyHG/2fd6P zCp+yUZS5+bSWOd+t/SPm+wewYtjkQ2wBJ0SwZPaqnzwX5T1cGTHty5CRc9YWiAQBlB6 JSqeaBEh0mEuEALlvdiAw5xZ6H3HFu3mKNrb9JOjLUTr5XYbf75JEdBJrM9f2K7jod8p 2kv/Bw+dtxuVpFrbOQT6uoERO0l+K7Aynb280Z/Gfds8y3Vm8w2SzEEiK8eVCHTolvAY vAzA== X-Gm-Message-State: AIkVDXLAAburRtPJG1iEIDQ5uo4ggLtcVOCFo4fO39HDFedW7hStQUcWIrWn1wMP9rrmY6CM X-Received: by 10.84.197.1 with SMTP id m1mr16495267pld.123.1486376812022; Mon, 06 Feb 2017 02:26:52 -0800 (PST) Received: from localhost ([122.172.165.189]) by smtp.gmail.com with ESMTPSA id b75sm1160751pfb.90.2017.02.06.02.26.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 02:26:51 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Zhang Rui , Eduardo Valentin Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Viresh Kumar , Dan Carpenter Subject: [PATCH 3/3] thermal: devfreq: Check OPP for errors Date: Mon, 6 Feb 2017 15:56:29 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: <232171cd9d89c2179e10e1f2aed71ad7fc1f7872.1486376756.git.viresh.kumar@linaro.org> References: <232171cd9d89c2179e10e1f2aed71ad7fc1f7872.1486376756.git.viresh.kumar@linaro.org> In-Reply-To: <232171cd9d89c2179e10e1f2aed71ad7fc1f7872.1486376756.git.viresh.kumar@linaro.org> References: <232171cd9d89c2179e10e1f2aed71ad7fc1f7872.1486376756.git.viresh.kumar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index cf71550b9d00..ee013fc02980 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -225,13 +225,20 @@ 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_warn_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_warn_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; }