summaryrefslogtreecommitdiffstats
path: root/drivers/idle
diff options
context:
space:
mode:
authorRichard Cochran <rcochran@linutronix.de>2016-04-06 17:00:52 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-04-07 22:10:56 +0200
commite9df69ccd1322e87eee10f28036fad9e6c71f8dd (patch)
tree0f51f52ff6d92a502dddb07814cdf19547030263 /drivers/idle
parent51319918bcc31f901646fc66348d41cf74ee0566 (diff)
downloadlinux-stable-e9df69ccd1322e87eee10f28036fad9e6c71f8dd.tar.gz
linux-stable-e9df69ccd1322e87eee10f28036fad9e6c71f8dd.tar.bz2
linux-stable-e9df69ccd1322e87eee10f28036fad9e6c71f8dd.zip
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: Richard Cochran <rcochran@linutronix.de> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/idle')
-rw-r--r--drivers/idle/intel_idle.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 4a1de3dcbf85..5dd741ff4de3 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -1210,19 +1210,20 @@ static int __init intel_idle_init(void)
if (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();
retval = cpuidle_register_driver(&intel_idle_driver);
if (retval) {
struct cpuidle_driver *drv = cpuidle_get_driver();
printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
drv ? drv->name : "none");
+ free_percpu(intel_idle_cpuidle_devices);
return retval;
}
- intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
- if (intel_idle_cpuidle_devices == NULL)
- return -ENOMEM;
-
cpu_notifier_register_begin();
for_each_online_cpu(i) {