- Return an error when a notifier callback has been registered already

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEzv7L6UO9uDPlPSfHEsHwGGHeVUoFAmHcE9wACgkQEsHwGGHe
 VUoMmw//QEFHlmmWH9rIz23/2xv6Y+mR0G9JXm3YHtraId7BA8Kr9VI+4fxBjNxA
 aeCrgBxFEOq32b44GpeKBj4U1QWNi3lHzg0lYmw8zTab0Lxkuh8tw/2Qc15iLfBv
 sJZ7VQZ39TxR70ng3Q7I7Dox1Gu4nlP9d8nO2boxkepTXxx6UFPYCRPgZoMm2EYH
 fw9CauJIb5j6Ka2EOU1wWn+IKaxGz/Moe6FEQY7CH8OaJW3zcXyWL4GFdc2sDB41
 hyi29mRte3PT1G4RAcakLDh7ME781bGCo2xHqtyaCBiCvRkex23TyZ9FEC35xcDb
 gs/0AMeC4z1XVX/quEqJWcQRHjvDQY3nMvWnS0vfCOtuqBSTdSffe6j0wvFS4cc8
 ks3JbePCeJNYoBG+71RAG8+J0ZsfOm1NS42vHCQ8PuGU0V67ca0r6oJqMGwZSwfl
 +iYWb68pvQkYX/kX7E7S3qe5PlXvB7XTo2WhOXeZbONwZf23qiqvjdGoQUhhX/ry
 G8bI3mojJG8U8bvViZYfVhnFscLnuLEqs3GJJGndwHyI7y7xIC/VsR7CZrfufDO9
 2r8NXQXI7PYmLsBKMPRFfIvmTXhZwIqNwsdBmrU0mGoFaMrWdrIMlQV8qCrPg2hT
 7YIxDzldmSlovYCUh7sh1y8fZmkhTXPgb3URluBkEPuzzi59Trg=
 =brI6
 -----END PGP SIGNATURE-----

Merge tag 'core_core_for_v5.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull notifier fix from Borislav Petkov:
 "Return an error when a notifier callback has been registered already"

* tag 'core_core_for_v5.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  notifier: Return an error when a callback has already been registered
This commit is contained in:
Linus Torvalds 2022-01-10 11:32:57 -08:00
commit 5ba13c1c4d

View file

@ -20,12 +20,13 @@ BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);
*/
static int notifier_chain_register(struct notifier_block **nl,
struct notifier_block *n)
struct notifier_block *n)
{
while ((*nl) != NULL) {
if (unlikely((*nl) == n)) {
WARN(1, "double register detected");
return 0;
WARN(1, "notifier callback %ps already registered",
n->notifier_call);
return -EEXIST;
}
if (n->priority > (*nl)->priority)
break;
@ -134,7 +135,7 @@ static int notifier_call_chain_robust(struct notifier_block **nl,
*
* Adds a notifier to an atomic notifier chain.
*
* Currently always returns zero.
* Returns 0 on success, %-EEXIST on error.
*/
int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
struct notifier_block *n)
@ -216,7 +217,7 @@ NOKPROBE_SYMBOL(atomic_notifier_call_chain);
* Adds a notifier to a blocking notifier chain.
* Must be called in process context.
*
* Currently always returns zero.
* Returns 0 on success, %-EEXIST on error.
*/
int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
struct notifier_block *n)
@ -335,7 +336,7 @@ EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
* Adds a notifier to a raw notifier chain.
* All locking must be provided by the caller.
*
* Currently always returns zero.
* Returns 0 on success, %-EEXIST on error.
*/
int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *n)
@ -406,7 +407,7 @@ EXPORT_SYMBOL_GPL(raw_notifier_call_chain);
* Adds a notifier to an SRCU notifier chain.
* Must be called in process context.
*
* Currently always returns zero.
* Returns 0 on success, %-EEXIST on error.
*/
int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
struct notifier_block *n)