lkml.org 
[lkml]   [2021]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] notifier: Return non-null when callback already registered
On Thu, May 20, 2021 at 10:20:33PM +0200, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
>
> The notifier registration routine doesn't return a proper error value
> when a callback has already been registered, leading people to track
> whether that regisration has happened at the call site:
>
> https://lore.kernel.org/amd-gfx/20210512013058.6827-1-mukul.joshi@amd.com/
>
> Which is unnecessary.
>
> Return a non-null to signal that case so that callers can act
> accordingly.
>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
> kernel/notifier.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/notifier.c b/kernel/notifier.c
> index 1b019cbca594..ff7a3198c5fc 100644
> --- a/kernel/notifier.c
> +++ b/kernel/notifier.c
> @@ -25,7 +25,7 @@ static int notifier_chain_register(struct notifier_block **nl,
> while ((*nl) != NULL) {
> if (unlikely((*nl) == n)) {
> WARN(1, "double register detected");

That should give a big clue^

> - return 0;
> + return 1;

How about -EBUSY here?

\
 
 \ /
  Last update: 2021-05-21 13:15    [W:0.149 / U:0.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site