lkml.org 
[lkml]   [2011]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] x86: fix error paths in microcode_init()
After failure of platform_device_register_simple(), microcode_dev_exit()
got called without the call to microcode_dev_init() already having taken
place.

After failure of microcode_dev_init(), no cleanup of previously carried
out setup was done at all.

As a result, microcode_dev_exit() can now get __exit tagged on it.

(Noticed while looking at the code, not because of having experienced
an actual problem.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
arch/x86/kernel/microcode_core.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

--- 3.2-rc4/arch/x86/kernel/microcode_core.c
+++ 3.2-rc4-x86-ucode-init-eh/arch/x86/kernel/microcode_core.c
@@ -256,7 +256,7 @@ static int __init microcode_dev_init(voi
return 0;
}

-static void microcode_dev_exit(void)
+static void __exit microcode_dev_exit(void)
{
misc_deregister(&microcode_dev);
}
@@ -519,10 +519,8 @@ static int __init microcode_init(void)

microcode_pdev = platform_device_register_simple("microcode", -1,
NULL, 0);
- if (IS_ERR(microcode_pdev)) {
- microcode_dev_exit();
+ if (IS_ERR(microcode_pdev))
return PTR_ERR(microcode_pdev);
- }

get_online_cpus();
mutex_lock(&microcode_mutex);
@@ -538,8 +536,18 @@ static int __init microcode_init(void)
}

error = microcode_dev_init();
- if (error)
+ if (error) {
+ get_online_cpus();
+ mutex_lock(&microcode_mutex);
+
+ sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver);
+
+ mutex_unlock(&microcode_mutex);
+ put_online_cpus();
+
+ platform_device_unregister(microcode_pdev);
return error;
+ }

register_syscore_ops(&mc_syscore_ops);
register_hotcpu_notifier(&mc_cpu_notifier);




\
 
 \ /
  Last update: 2011-12-02 14:37    [W:0.064 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site