From patchwork Fri Oct 4 16:23:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: durgadoss.r@intel.com X-Patchwork-Id: 2988061 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@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 8DE93BFF0B for ; Fri, 4 Oct 2013 10:55:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F30CF202B4 for ; Fri, 4 Oct 2013 10:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D381420278 for ; Fri, 4 Oct 2013 10:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751325Ab3JDKzf (ORCPT ); Fri, 4 Oct 2013 06:55:35 -0400 Received: from mga14.intel.com ([143.182.124.37]:20973 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431Ab3JDKze (ORCPT ); Fri, 4 Oct 2013 06:55:34 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 04 Oct 2013 03:55:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,1032,1371106800"; d="scan'208";a="303109502" Received: from durga-linux.iind.intel.com ([10.223.86.44]) by AZSMGA002.ch.intel.com with ESMTP; 04 Oct 2013 03:55:31 -0700 From: Durgadoss R To: rui.zhang@intel.com, eduardo.valentin@ti.com, linux-pm@vger.kernel.org Cc: jacob.jun.pan@linux.intel.com, Durgadoss R Subject: [PATCH] Thermal: Tidy up error handling in powerclamp_init Date: Fri, 4 Oct 2013 21:53:24 +0530 Message-Id: <1380903804-18913-1-git-send-email-durgadoss.r@intel.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_03_06, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch * adds missing kfree() for cpu_clamping_mask * adds return value checking for alloc_percpu() * unregister hotcpu notifier in exit path Signed-off-by: Durgadoss R --- drivers/thermal/intel_powerclamp.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c index b40b37c..a7cd170 100644 --- a/drivers/thermal/intel_powerclamp.c +++ b/drivers/thermal/intel_powerclamp.c @@ -758,21 +758,39 @@ static int powerclamp_init(void) /* probe cpu features and ids here */ retval = powerclamp_probe(); if (retval) - return retval; + goto exit_free; + /* set default limit, maybe adjusted during runtime based on feedback */ window_size = 2; register_hotcpu_notifier(&powerclamp_cpu_notifier); + powerclamp_thread = alloc_percpu(struct task_struct *); + if (!powerclamp_thread) { + retval = -ENOMEM; + goto exit_unregister; + } + cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL, &powerclamp_cooling_ops); - if (IS_ERR(cooling_dev)) - return -ENODEV; + if (IS_ERR(cooling_dev)) { + retval = -ENODEV; + goto exit_free_thread; + } if (!duration) duration = jiffies_to_msecs(DEFAULT_DURATION_JIFFIES); + powerclamp_create_debug_files(); return 0; + +exit_free_thread: + free_percpu(powerclamp_thread); +exit_unregister: + unregister_hotcpu_notifier(&powerclamp_cpu_notifier); +exit_free: + kfree(cpu_clamping_mask); + return retval; } module_init(powerclamp_init);