Commit bd399063 authored by Srivatsa S. Bhat's avatar Srivatsa S. Bhat Committed by Borislav Petkov

x86, microcode: Fix the failure path of microcode update driver init code

The microcode update driver's initialization code does not handle
failures correctly. This patch fixes this issue.
Signed-off-by: default avatarJan Beulich <JBeulich@suse.com>
Signed-off-by: default avatarSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20111107123530.12164.31227.stgit@srivatsabhat.in.ibm.com
Link: http://lkml.kernel.org/r/4ED8E2270200007800065120@nat28.tlf.novell.comSigned-off-by: default avatarBorislav Petkov <borislav.petkov@amd.com>
parent 8e8da023
......@@ -256,7 +256,7 @@ static int __init microcode_dev_init(void)
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);
......@@ -532,14 +530,12 @@ static int __init microcode_init(void)
mutex_unlock(&microcode_mutex);
put_online_cpus();
if (error) {
platform_device_unregister(microcode_pdev);
return error;
}
if (error)
goto out_pdev;
error = microcode_dev_init();
if (error)
return error;
goto out_sysdev_driver;
register_syscore_ops(&mc_syscore_ops);
register_hotcpu_notifier(&mc_cpu_notifier);
......@@ -548,6 +544,20 @@ static int __init microcode_init(void)
" <tigran@aivazian.fsnet.co.uk>, Peter Oruba\n");
return 0;
out_sysdev_driver:
get_online_cpus();
mutex_lock(&microcode_mutex);
sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver);
mutex_unlock(&microcode_mutex);
put_online_cpus();
out_pdev:
platform_device_unregister(microcode_pdev);
return error;
}
module_init(microcode_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment