[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211108101157.15189-2-bp@alien8.de>
Date: Mon, 8 Nov 2021 11:11:16 +0100
From: Borislav Petkov <bp@...en8.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: x86@...nel.org
Subject: [PATCH v0 01/42] x86: Check notifier registration return value
From: Borislav Petkov <bp@...e.de>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by: Borislav Petkov <bp@...e.de>
Cc: x86@...nel.org
---
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
Powered by blists - more mailing lists