# Re: \[PATCH v4 06/25\] reboot: Warn if unregister\_restart\_handler() fails

- From: Rafael J. Wysocki \<rafael@kernel.org\>
- Date: 2021-12-10 18:32:42 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2021/12/1604275
- Thread: https://ratatoskr.run/linux-mips/2021/11/1588062/t.md

```text
On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko [ref] wrote:
>
> 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.  Why WARN() about this?  And what about systems with
panic_on_warn set?

>  }
>  EXPORT_SYMBOL(unregister_restart_handler);
>
> --
> 2.33.1
>
```
