Thread (63 messages) 63 messages, 4 authors, 2021-12-13

Re: [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails

From: Dmitry Osipenko <digetx@gmail.com>
Date: 2021-12-10 18:54:25
Also in: linux-acpi, linux-m68k, linux-mips, linux-pm, linux-riscv, linux-sh, linux-tegra, lkml, xen-devel

10.12.2021 21:32, Rafael J. Wysocki пишет:
On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko [off-list ref] wrote:
quoted
Emit warning if unregister_restart_handler() fails since it never should
fail. This will ease further API development by catching mistakes early.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 kernel/reboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/reboot.c b/kernel/reboot.c
index e6659ae329f1..f0e7b9c13f6b 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler);
  */
 int unregister_restart_handler(struct notifier_block *nb)
 {
-       return atomic_notifier_chain_unregister(&restart_handler_list, nb);
+       return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb));
The only reason why it can fail is if the object pointed to by nb is
not in the chain.
I had exactly this case where object wasn't in the chain due to a bug
and this warning was very helpful.
 Why WARN() about this?  And what about systems with
panic_on_warn set?
That warning condition will never happen normally, only when something
is seriously wrong.

Those systems with panic_on_warn will get what was they asked for.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help