[PATCH v0 34/42] powerpc: Check notifier registration return value

From: Borislav Petkov
Date: Mon Nov 08 2021 - 05:16:41 EST


From: Borislav Petkov <bp@xxxxxxx>

Avoid homegrown notifier registration checks.

No functional changes.

Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
---
arch/powerpc/kernel/setup-common.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index b1e43b69a559..32f9900cd4f4 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -725,14 +725,18 @@ static struct notifier_block kernel_offset_notifier = {

void __init setup_panic(void)
{
- if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
- atomic_notifier_chain_register(&panic_notifier_list,
- &kernel_offset_notifier);
+ if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0) {
+ if (atomic_notifier_chain_register(&panic_notifier_list,
+ &kernel_offset_notifier))
+ pr_warn("Kernel offset notifier already registered\n");
+ }

/* PPC64 always does a hard irq disable in its panic handler */
if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic)
return;
- atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
+
+ if (atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block))
+ pr_warn("Panic notifier already registered\n");
}

#ifdef CONFIG_CHECK_CACHE_COHERENCY
--
2.29.2