From patchwork Tue Apr 9 21:59:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 2417971 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 409D6DFE82 for ; Tue, 9 Apr 2013 21:59:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934324Ab3DIV7W (ORCPT ); Tue, 9 Apr 2013 17:59:22 -0400 Received: from mail-oa0-f73.google.com ([209.85.219.73]:51645 "EHLO mail-oa0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761010Ab3DIV7V (ORCPT ); Tue, 9 Apr 2013 17:59:21 -0400 Received: by mail-oa0-f73.google.com with SMTP id o6so1888527oag.0 for ; Tue, 09 Apr 2013 14:59:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=v7V90ZYAouBt9j0vdfWJHSzW8jyVB+seKX+LHkG4Kw0=; b=heyyka4+Fk/Tm4ZOGnGbFYMUYA1J64G/jE9dZstAY7nA4R0x/RBPbJEZNYoBOMhPn+ lAGBbBJSUmNZrcpL1sjVbgd4lzYpdKYBJCjsOoILsF3mbHqIIEOEDYcrvMjUnFQGCdgS nfXN8w3eANeMfEfLIXclC6CpMtz6IdU9pU30meQ2euOWRvJnXsRChcM+zMOAjvinFsve OxwV0ld/YemeWS7TX7N9Z13+Eh7aHYhsFzBIT6mJk9tzmCI87PjQRqMnxnl2gSgganIu cm0RV5QV2k83bqeijiaM2etMzxCO7zPkf5nPK4N0vmwZ4zRCfeYrbvi3j+6fxOWY8Bhx Xe3w== X-Received: by 10.50.45.168 with SMTP id o8mr13665946igm.5.1365544761038; Tue, 09 Apr 2013 14:59:21 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id j7si2342174igc.3.2013.04.09.14.59.20 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 09 Apr 2013 14:59:21 -0700 (PDT) Received: from abrestic.mtv.corp.google.com (abrestic.mtv.corp.google.com [172.22.72.111]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 52D9531C15F; Tue, 9 Apr 2013 14:59:20 -0700 (PDT) Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id E009C221471; Tue, 9 Apr 2013 14:59:19 -0700 (PDT) From: Andrew Bresticker To: Zhang Rui , Eduardo Valentin , Kukjin Kim Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Andrew Bresticker Subject: [PATCH] thermal: exynos: fix handling of invalid frequency table entries Date: Tue, 9 Apr 2013 14:59:18 -0700 Message-Id: <1365544758-15245-1-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 1.8.1.3 X-Gm-Message-State: ALoCoQlH9sUlYPrik2KjBAG0xy/bOFYs8qlspbWadJIpqSVJLM6EpAsg/n67N3cm289s4fOpGfRbI76/dR8rOkzDTIXRyy/KaN5cGHVp5UovoZqHpVn8CamiGwFHtq7LsIO7LtCreXmxPju09jkszJD02Octr5eMDL/aOVr/Oqj/HNPVvIad8BaeipStGAQPJq8Fq5iHFBSPoU59zKY+1ffqhgeguWTdaw== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Similar to the error described in "thermal: cpu_cooling: fix handling of invalid frequency table entries," exynos_get_frequency_level() will enter an infinite loop if any CPU frequency table entries are invalid. This patch fixes the handling of invalid frequency entries so that there is no infinite loop and the correct level is returned. Signed-off-by: Andrew Bresticker --- drivers/thermal/exynos_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index d5e6267..524b2a0 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -237,7 +237,7 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal, static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq) { - int i = 0, ret = -EINVAL; + int i, level = 0, ret = -EINVAL; struct cpufreq_frequency_table *table = NULL; #ifdef CONFIG_CPU_FREQ table = cpufreq_frequency_get_table(cpu); @@ -245,12 +245,12 @@ static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq) if (!table) return ret; - while (table[i].frequency != CPUFREQ_TABLE_END) { + for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { if (table[i].frequency == CPUFREQ_ENTRY_INVALID) continue; if (table[i].frequency == freq) - return i; - i++; + return level; + level++; } return ret; }