From patchwork Tue Sep 22 16:35:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 54005 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 79E0D22B1E for ; Tue, 22 Sep 2015 16:35:55 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf11031309wic.2 for ; Tue, 22 Sep 2015 09:35:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=6jSIDbp/9F90RBY2hAEq+ZcwY9GVdV6FNBP5O8Gg/X4=; b=hgrYiMU7Hx3jfxA8io7duWxMb8UlgB4AiKq2hGgRCxp5OfYCWXnhQhV7CrLSgJfksi r63n4BT13jWhVa0nRsUK3tUsSQzfMenawfR5Gs7D8EK4pC6phJAxzQGaeGy5HLUrVPtK r4bwUlXxhZPryPYDoz+sbigWG9oNw/+yeK0bLoZyxfpflXmXaOKjoWpAcTSG5CBI9YLN T5Rxsjfn04llY2uRWnE2amK1s4dDxhM5Z+h1Gp9ERibUwPgarcAzh3+jZfGz+h3QHBfs FDew+Mok3rhp9Qmmoe7J7NDYNHnz/2x2+E7uwmFAa9KXtZ42cgNBbp/roFJgRD86Asdi d1tA== X-Gm-Message-State: ALoCoQmKfDq8M5GLulzWd1MrB8ZKea/h3ItPFTWQNXxsWPN6F9AxUjSb338ez7XP+EACcYODJ0vb X-Received: by 10.194.109.233 with SMTP id hv9mr4488900wjb.1.1442939754809; Tue, 22 Sep 2015 09:35:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.32.207 with SMTP id g198ls55045lfg.18.gmail; Tue, 22 Sep 2015 09:35:54 -0700 (PDT) X-Received: by 10.152.178.162 with SMTP id cz2mr10061117lac.89.1442939754656; Tue, 22 Sep 2015 09:35:54 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id s3si1651789lae.143.2015.09.22.09.35.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2015 09:35:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lagj9 with SMTP id j9so19868700lag.2 for ; Tue, 22 Sep 2015 09:35:54 -0700 (PDT) X-Received: by 10.152.161.232 with SMTP id xv8mr10357117lab.32.1442939754539; Tue, 22 Sep 2015 09:35:54 -0700 (PDT) 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.59.35 with SMTP id w3csp591661lbq; Tue, 22 Sep 2015 09:35:53 -0700 (PDT) X-Received: by 10.50.78.231 with SMTP id e7mr18260103igx.88.1442939753444; Tue, 22 Sep 2015 09:35:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si13541786iga.58.2015.09.22.09.35.51; Tue, 22 Sep 2015 09:35:53 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758701AbbIVQfu (ORCPT + 12 others); Tue, 22 Sep 2015 12:35:50 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:33260 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758607AbbIVQft (ORCPT ); Tue, 22 Sep 2015 12:35:49 -0400 Received: by pacex6 with SMTP id ex6so13691720pac.0 for ; Tue, 22 Sep 2015 09:35:49 -0700 (PDT) X-Received: by 10.66.165.106 with SMTP id yx10mr32369898pab.102.1442939749203; Tue, 22 Sep 2015 09:35:49 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id w5sm3231867pbs.31.2015.09.22.09.35.48 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Sep 2015 09:35:48 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, nm@ti.com, Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH V2] PM / OPP: of_property_count_u32_elems() can return errors Date: Tue, 22 Sep 2015 09:35:31 -0700 Message-Id: <3ad0ce115028e628e556a505689d396b6e98f04e.1442939340.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 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.47 as permitted sender) smtp.mailfrom=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: , of_property_count_u32_elems() will never return 0, but a -ve error value of a positive count. And so the current !count check is wrong. Also, a missing "opp-microvolt" property isn't a problem and so we need to do of_find_property() separately to confirm that. Fixes: 274659029c9d ("PM / OPP: Add support to parse "operating-points-v2" bindings") Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- V1->V2: - Dropped 'prop' variable. drivers/base/power/opp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 28cd75c535b0..1194669c2bb5 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -892,10 +892,17 @@ static int opp_get_microvolt(struct dev_pm_opp *opp, struct device *dev) u32 microvolt[3] = {0}; int count, ret; - count = of_property_count_u32_elems(opp->np, "opp-microvolt"); - if (!count) + /* Missing property isn't a problem, but an invalid entry is */ + if (!of_find_property(opp->np, "opp-microvolt", NULL)) return 0; + count = of_property_count_u32_elems(opp->np, "opp-microvolt"); + if (count < 0) { + dev_err(dev, "%s: Invalid opp-microvolt property (%d)\n", + __func__, count); + return count; + } + /* There can be one or three elements here */ if (count != 1 && count != 3) { dev_err(dev, "%s: Invalid number of elements in opp-microvolt property (%d)\n",