notifier: Return an error when a callback has already been registered
authorBorislav Petkov <bp@suse.de>
Wed, 1 Dec 2021 21:28:14 +0000 (22:28 +0100)
committerBorislav Petkov <bp@suse.de>
Wed, 29 Dec 2021 09:37:33 +0000 (10:37 +0100)
commit5abb065dca7301de90b7c44bbcdc378e49e4d362
tree2bf97dbf77f38ff9e39921a1d79bb61e972f5951
parentfc74e0a40e4f9fd0468e34045b0c45bba11dcbb2
notifier: Return an error when a callback has already been registered

Return -EEXIST when a notifier callback has already been registered on a
notifier chain.

This should avoid any homegrown registration tracking at the callsite
like

  https://lore.kernel.org/amd-gfx/20210512013058.6827-1-mukul.joshi@amd.com

for example.

This version is an alternative of

  https://lore.kernel.org/r/20211108101157.15189-1-bp@alien8.de

which needed to touch every caller not checking the registration
routine's return value.

Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/YcSWNdUBS8A2ZB3s@zn.tnic
kernel/notifier.c