From patchwork Wed Feb 26 03:38:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 3720581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41F9DBF13A for ; Wed, 26 Feb 2014 03:39:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 638AF201F7 for ; Wed, 26 Feb 2014 03:39:30 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECCA220200 for ; Wed, 26 Feb 2014 03:39:28 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIVKw-0005Co-8c; Wed, 26 Feb 2014 03:39:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIVKt-0008No-Sw; Wed, 26 Feb 2014 03:39:07 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIVKr-0008Md-5X for linux-arm-kernel@lists.infradead.org; Wed, 26 Feb 2014 03:39:06 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id A5F6813EFE8; Wed, 26 Feb 2014 03:38:43 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 997B813F121; Wed, 26 Feb 2014 03:38:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from skannan1-linux.qualcomm.com (i-global252.qualcomm.com [199.106.103.252]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skannan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2685D13EFE8; Wed, 26 Feb 2014 03:38:43 +0000 (UTC) From: Saravana Kannan To: "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 2/3] cpufreq: stats: Fix error handling in __cpufreq_stats_create_table() Date: Tue, 25 Feb 2014 19:38:34 -0800 Message-Id: <1393385915-19138-2-git-send-email-skannan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1789244.B5CzWbcp6h@vostro.rjw.lan> References: <1789244.B5CzWbcp6h@vostro.rjw.lan> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140225_223905_343136_8E5051B7 X-CRM114-Status: GOOD ( 12.79 ) X-Spam-Score: -1.9 (-) Cc: linux-arm-msm@vger.kernel.org, Saravana Kannan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Remove sysfs group if __cpufreq_stats_create_table() fails after creating one. Change-Id: Icb0b44424cc4eb6c88be255e2839ef51c3f8779c Signed-off-by: Saravana Kannan Acked-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index e4bd27f..c52b440 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -216,7 +216,7 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy, stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL); if (!stat->time_in_state) { ret = -ENOMEM; - goto error_out; + goto error_alloc; } stat->freq_table = (unsigned int *)(stat->time_in_state + count); @@ -237,6 +237,8 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy, stat->last_index = freq_table_get_index(stat, policy->cur); spin_unlock(&cpufreq_stats_lock); return 0; +error_alloc: + sysfs_remove_group(&policy->kobj, &stats_attr_group); error_out: kfree(stat); per_cpu(cpufreq_stats_table, cpu) = NULL;