Re: [PATCH] notifier: Return an error when a callback has already been registered

From: Sebastian Andrzej Siewior
Date: Thu Dec 02 2021 - 09:17:00 EST


On 2021-12-02 14:36:01 [+0100], Borislav Petkov wrote:
> --- a/kernel/notifier.c
> +++ b/kernel/notifier.c
> @@ -19,14 +19,12 @@ BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);
> * are layered on top of these, with appropriate locking added.
> */
>
> -static int notifier_chain_register(struct notifier_block **nl,
> - struct notifier_block *n)
> +static int __notifier_chain_register(struct notifier_block **nl,
> + struct notifier_block *n)
> {
> while ((*nl) != NULL) {
> - if (unlikely((*nl) == n)) {
> - WARN(1, "double register detected");
> - return 0;

This could be s/0/-EEXIST/ or do I miss something?
I appreciate the updated warning with %ps!

> - }
> + if (unlikely((*nl) == n))
> + return -EEXIST;
> if (n->priority > (*nl)->priority)
> break;
> nl = &((*nl)->next);

Sebastian