mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-15 23:25:07 +00:00
Thermal: Tidy up error handling in powerclamp_init
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> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
This commit is contained in:
parent
22356f447c
commit
c32a5087b7
1 changed files with 21 additions and 3 deletions
|
@ -758,21 +758,39 @@ static int powerclamp_init(void)
|
||||||
/* probe cpu features and ids here */
|
/* probe cpu features and ids here */
|
||||||
retval = powerclamp_probe();
|
retval = powerclamp_probe();
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
goto exit_free;
|
||||||
|
|
||||||
/* set default limit, maybe adjusted during runtime based on feedback */
|
/* set default limit, maybe adjusted during runtime based on feedback */
|
||||||
window_size = 2;
|
window_size = 2;
|
||||||
register_hotcpu_notifier(&powerclamp_cpu_notifier);
|
register_hotcpu_notifier(&powerclamp_cpu_notifier);
|
||||||
|
|
||||||
powerclamp_thread = alloc_percpu(struct task_struct *);
|
powerclamp_thread = alloc_percpu(struct task_struct *);
|
||||||
|
if (!powerclamp_thread) {
|
||||||
|
retval = -ENOMEM;
|
||||||
|
goto exit_unregister;
|
||||||
|
}
|
||||||
|
|
||||||
cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
|
cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
|
||||||
&powerclamp_cooling_ops);
|
&powerclamp_cooling_ops);
|
||||||
if (IS_ERR(cooling_dev))
|
if (IS_ERR(cooling_dev)) {
|
||||||
return -ENODEV;
|
retval = -ENODEV;
|
||||||
|
goto exit_free_thread;
|
||||||
|
}
|
||||||
|
|
||||||
if (!duration)
|
if (!duration)
|
||||||
duration = jiffies_to_msecs(DEFAULT_DURATION_JIFFIES);
|
duration = jiffies_to_msecs(DEFAULT_DURATION_JIFFIES);
|
||||||
|
|
||||||
powerclamp_create_debug_files();
|
powerclamp_create_debug_files();
|
||||||
|
|
||||||
return 0;
|
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);
|
module_init(powerclamp_init);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue