diff mbox

Thermal: Tidy up error handling in powerclamp_init

Message ID 1380903804-18913-1-git-send-email-durgadoss.r@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

durgadoss.r@intel.com Oct. 4, 2013, 4:23 p.m. UTC
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 <durgadoss.r@intel.com>
---
 drivers/thermal/intel_powerclamp.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

Comments

Jacob Pan Oct. 4, 2013, 4:37 p.m. UTC | #1
On Fri,  4 Oct 2013 21:53:24 +0530
Durgadoss R <durgadoss.r@intel.com> wrote:

> This patch
>  * adds missing kfree() for cpu_clamping_mask
>  * adds return value checking for alloc_percpu()
>  * unregister hotcpu notifier in exit path
looks good. thanks for the fix.

Jacob
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Rui Oct. 9, 2013, 4:18 a.m. UTC | #2
On Fri, 2013-10-04 at 21:53 +0530, Durgadoss R wrote:
> 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 <durgadoss.r@intel.com>

applied to thermal -next.

thanks,
rui

> ---
>  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);
>  


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);