x86/mce: Do not register notifiers with invalid prio
authorBorislav Petkov <bp@suse.de>
Mon, 27 Mar 2017 09:33:04 +0000 (11:33 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 28 Mar 2017 06:55:15 +0000 (08:55 +0200)
This is just a defensive precaution: do not register notifiers with a
priority which would disrupt the error handling in the notifiers with
prio higher than MCE_PRIO_EDAC.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20170327093304.10683-7-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/mcheck/mce.c

index 36082c7..a09bb67 100644 (file)
@@ -157,9 +157,10 @@ static atomic_t num_notifiers;
 
 void mce_register_decode_chain(struct notifier_block *nb)
 {
-       atomic_inc(&num_notifiers);
+       if (WARN_ON(nb->priority > MCE_PRIO_LOWEST && nb->priority < MCE_PRIO_EDAC))
+               return;
 
-       WARN_ON(nb->priority > MCE_PRIO_LOWEST && nb->priority < MCE_PRIO_EDAC);
+       atomic_inc(&num_notifiers);
 
        atomic_notifier_chain_register(&x86_mce_decoder_chain, nb);
 }