Re: [RFC PATCH] notifier: Return non-null when callback already registered
From: Borislav Petkov
Date: Fri May 21 2021 - 10:06:59 EST
On Fri, May 21, 2021 at 01:11:42PM +0200, Peter Zijlstra wrote:
> > @@ -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^
Yah, the big cluebat... Was wondering whether to remove it, actually.
But then I'd need to audit all users whether they handle retval
properly. Sounds like a kernelnewbies project to me...
> > - return 0;
> > + return 1;
>
> How about -EBUSY here?
Yah, anthing but 0.
But if we're gonna return -E things, -EEXIST looks like an even better
fit to me...
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette