public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] x86: Fix mcheck_init_device() to handle misc_register() correctly
@ 2011-03-04 13:29 J.P. Lacerda
  2011-03-04 17:16 ` Borislav Petkov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: J.P. Lacerda @ 2011-03-04 13:29 UTC (permalink / raw)
  To: akpm, johan.wessfeldt, tglx, mingo, x86, linux-kernel; +Cc: J.P. Lacerda

The return value for misc_register() was not being taken into account.
Furthermore, if misc_register() fails, we must rollback any changes made by
mcheck_init_device()

Signed-off-by: J.P. Lacerda <jp.lacerda@codethink.co.uk>
---
 arch/x86/kernel/cpu/mcheck/mce.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d916183..20c2c44 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2140,7 +2140,18 @@ static __init int mcheck_init_device(void)
 	}
 
 	register_hotcpu_notifier(&mce_cpu_notifier);
-	misc_register(&mce_log_device);
+	err = misc_register(&mce_log_device);
+
+	if (err) {
+		unregister_hotcpu_notifier(&mce_cpu_notifier);
+
+		for_each_online_cpu(i) {
+			mce_remove_device(i);
+		}
+
+		sysdev_class_unregister(&mce_sysclass);
+		free_cpumask_var(mce_dev_initialized);
+	}
 
 	return err;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-05 12:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-04 13:29 [PATCH 1/1] x86: Fix mcheck_init_device() to handle misc_register() correctly J.P. Lacerda
2011-03-04 17:16 ` Borislav Petkov
2011-03-04 21:07   ` Johan Wessfeldt
2011-03-05 12:56     ` Borislav Petkov
2011-03-04 18:17 ` Dan Carpenter
2011-03-04 21:38 ` Johan Wessfeldt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox