[PATCH v0 01/42] x86: Check notifier registration return value
From: Borislav Petkov
Date: Mon Nov 08 2021 - 05:12:36 EST
From: Borislav Petkov <bp@xxxxxxx>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Cc: x86@xxxxxxxxxx
---
arch/x86/kernel/cpu/mce/core.c | 3 ++-
arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 ++-
arch/x86/kernel/setup.c | 7 +++++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 6ed365337a3b..2c4a9ff49384 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -164,7 +164,8 @@ void mce_register_decode_chain(struct notifier_block *nb)
nb->priority > MCE_PRIO_HIGHEST))
return;
- blocking_notifier_chain_register(&x86_mce_decoder_chain, nb);
+ if (blocking_notifier_chain_register(&x86_mce_decoder_chain, nb))
+ pr_warn("MCE decoder chain notifier already registered\n");
}
EXPORT_SYMBOL_GPL(mce_register_decode_chain);
diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c
index 100fbeebdc72..efa503a512dd 100644
--- a/arch/x86/kernel/cpu/mce/dev-mcelog.c
+++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c
@@ -281,7 +281,8 @@ static long mce_chrdev_ioctl(struct file *f, unsigned int cmd,
void mce_register_injector_chain(struct notifier_block *nb)
{
- blocking_notifier_chain_register(&mce_injector_chain, nb);
+ if (blocking_notifier_chain_register(&mce_injector_chain, nb))
+ pr_warn("MCE injector notifier already registered\n");
}
EXPORT_SYMBOL_GPL(mce_register_injector_chain);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 40ed44ead063..e28cd4dd81c1 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1245,8 +1245,11 @@ static struct notifier_block kernel_offset_notifier = {
static int __init register_kernel_offset_dumper(void)
{
- atomic_notifier_chain_register(&panic_notifier_list,
- &kernel_offset_notifier);
+ int ret = atomic_notifier_chain_register(&panic_notifier_list,
+ &kernel_offset_notifier);
+ if (ret)
+ pr_warn("Kernel offset dumper notifier already registered\n");
+
return 0;
}
__initcall(register_kernel_offset_dumper);
--
2.29.2