From patchwork Wed May 25 23:38:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 818782 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4PNdRBC010531 for ; Wed, 25 May 2011 23:39:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932237Ab1EYXjZ (ORCPT ); Wed, 25 May 2011 19:39:25 -0400 Received: from na3sys009aog107.obsmtp.com ([74.125.149.197]:33704 "EHLO na3sys009aog107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932218Ab1EYXjZ (ORCPT ); Wed, 25 May 2011 19:39:25 -0400 Received: from mail-gx0-f176.google.com ([209.85.161.176]) (using TLSv1) by na3sys009aob107.postini.com ([74.125.148.12]) with SMTP ID DSNKTd2TLI0UAW2gv5sfyJQCsOLIbfZveMdr@postini.com; Wed, 25 May 2011 16:39:24 PDT Received: by mail-gx0-f176.google.com with SMTP id 7so110902gxk.35 for ; Wed, 25 May 2011 16:39:24 -0700 (PDT) Received: by 10.90.194.14 with SMTP id r14mr262231agf.125.1306366764395; Wed, 25 May 2011 16:39:24 -0700 (PDT) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id i6sm240975anm.25.2011.05.25.16.39.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 16:39:23 -0700 (PDT) From: Nishanth Menon To: linux-omap Cc: Kevin , Nishanth Menon Subject: [PM-WIP_CPUFREQ][PATCH V3 7/8] OMAP2+: cpufreq: put clk if cpu_init failed Date: Wed, 25 May 2011 16:38:52 -0700 Message-Id: <1306366733-8439-8-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1306366733-8439-1-git-send-email-nm@ti.com> References: <1306366733-8439-1-git-send-email-nm@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 25 May 2011 23:39:27 +0000 (UTC) Release the mpu_clk in fail paths. Reported-by: Todd Poynor Signed-off-by: Nishanth Menon --- arch/arm/mach-omap2/omap2plus-cpufreq.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c index f026ac4..594100e 100644 --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c @@ -226,8 +226,10 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) if (IS_ERR(mpu_clk)) return PTR_ERR(mpu_clk); - if (policy->cpu >= NR_CPUS) - return -EINVAL; + if (policy->cpu >= NR_CPUS) { + result = -EINVAL; + goto fail1; + } policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu); @@ -235,7 +237,7 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) if (result || !freq_table) { dev_err(mpu_dev, "%s: cpu%d: unable to get freq table [%d]\n", __func__, policy->cpu, result); - return result; + goto fail1; } mutex_lock(&freq_table_lock); @@ -244,8 +246,7 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) mutex_unlock(&freq_table_lock); dev_err(mpu_dev, "%s: cpu%d: unable to get cpuinfo [%d]\n", __func__, policy->cpu, result); - freq_table_free(); - return result; + goto fail2; } cpufreq_frequency_table_get_attr(freq_table, policy->cpu); mutex_unlock(&freq_table_lock); @@ -271,6 +272,12 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = 300 * 1000; return 0; + +fail2: + freq_table_free(); +fail1: + clk_put(mpu_clk); + return result; } static int omap_cpu_exit(struct cpufreq_policy *policy)