[PATCH v0 11/42] misc: Check notifier registration return value

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


From: Borislav Petkov <bp@xxxxxxx>

Avoid homegrown notifier registration checks.

No functional changes.

Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/misc/ibmasm/heartbeat.c | 3 ++-
drivers/misc/pvpanic/pvpanic.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/ibmasm/heartbeat.c b/drivers/misc/ibmasm/heartbeat.c
index 59c9a0d95659..f7c22d9a768b 100644
--- a/drivers/misc/ibmasm/heartbeat.c
+++ b/drivers/misc/ibmasm/heartbeat.c
@@ -39,7 +39,8 @@ static struct notifier_block panic_notifier = { panic_happened, NULL, 1 };

void ibmasm_register_panic_notifier(void)
{
- atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier);
+ if (atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier))
+ pr_warn("IBM ASM panic notifier already registered\n");
}

void ibmasm_unregister_panic_notifier(void)
diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c
index 4b8f1c7d726d..6e89e8b1beaf 100644
--- a/drivers/misc/pvpanic/pvpanic.c
+++ b/drivers/misc/pvpanic/pvpanic.c
@@ -95,7 +95,8 @@ static int pvpanic_init(void)
INIT_LIST_HEAD(&pvpanic_list);
spin_lock_init(&pvpanic_lock);

- atomic_notifier_chain_register(&panic_notifier_list, &pvpanic_panic_nb);
+ if (atomic_notifier_chain_register(&panic_notifier_list, &pvpanic_panic_nb))
+ pr_warn("PV panic notifier already registered\n");

return 0;
}
--
2.29.2