提交 e9df69cc 编写于 作者: R Richard Cochran 提交者: Rafael J. Wysocki

intel_idle: Fix dangling registration on error path.

In the module_init() method, if the per-CPU allocation fails, then the
active cpuidle registration is not cleaned up.  This patch fixes the
issue by attempting the allocation before registration, and then
cleaning it up again on registration failure.
Signed-off-by: NRichard Cochran <rcochran@linutronix.de>
Signed-off-by: NLen Brown <len.brown@intel.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 51319918
...@@ -1210,19 +1210,20 @@ static int __init intel_idle_init(void) ...@@ -1210,19 +1210,20 @@ static int __init intel_idle_init(void)
if (retval) if (retval)
return retval; return retval;
intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
if (intel_idle_cpuidle_devices == NULL)
return -ENOMEM;
intel_idle_cpuidle_driver_init(); intel_idle_cpuidle_driver_init();
retval = cpuidle_register_driver(&intel_idle_driver); retval = cpuidle_register_driver(&intel_idle_driver);
if (retval) { if (retval) {
struct cpuidle_driver *drv = cpuidle_get_driver(); struct cpuidle_driver *drv = cpuidle_get_driver();
printk(KERN_DEBUG PREFIX "intel_idle yielding to %s", printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
drv ? drv->name : "none"); drv ? drv->name : "none");
free_percpu(intel_idle_cpuidle_devices);
return retval; return retval;
} }
intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
if (intel_idle_cpuidle_devices == NULL)
return -ENOMEM;
cpu_notifier_register_begin(); cpu_notifier_register_begin();
for_each_online_cpu(i) { for_each_online_cpu(i) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册