Skip to content

Commit 5ba13c1

Browse files
committed
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
2 parents 133d9c5 + 5abb065 commit 5ba13c1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

kernel/notifier.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);
2020
*/
2121

2222
static int notifier_chain_register(struct notifier_block **nl,
23-
struct notifier_block *n)
23+
struct notifier_block *n)
2424
{
2525
while ((*nl) != NULL) {
2626
if (unlikely((*nl) == n)) {
27-
WARN(1, "double register detected");
28-
return 0;
27+
WARN(1, "notifier callback %ps already registered",
28+
n->notifier_call);
29+
return -EEXIST;
2930
}
3031
if (n->priority > (*nl)->priority)
3132
break;
@@ -134,7 +135,7 @@ static int notifier_call_chain_robust(struct notifier_block **nl,
134135
*
135136
* Adds a notifier to an atomic notifier chain.
136137
*
137-
* Currently always returns zero.
138+
* Returns 0 on success, %-EEXIST on error.
138139
*/
139140
int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
140141
struct notifier_block *n)
@@ -216,7 +217,7 @@ NOKPROBE_SYMBOL(atomic_notifier_call_chain);
216217
* Adds a notifier to a blocking notifier chain.
217218
* Must be called in process context.
218219
*
219-
* Currently always returns zero.
220+
* Returns 0 on success, %-EEXIST on error.
220221
*/
221222
int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
222223
struct notifier_block *n)
@@ -335,7 +336,7 @@ EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
335336
* Adds a notifier to a raw notifier chain.
336337
* All locking must be provided by the caller.
337338
*
338-
* Currently always returns zero.
339+
* Returns 0 on success, %-EEXIST on error.
339340
*/
340341
int raw_notifier_chain_register(struct raw_notifier_head *nh,
341342
struct notifier_block *n)
@@ -406,7 +407,7 @@ EXPORT_SYMBOL_GPL(raw_notifier_call_chain);
406407
* Adds a notifier to an SRCU notifier chain.
407408
* Must be called in process context.
408409
*
409-
* Currently always returns zero.
410+
* Returns 0 on success, %-EEXIST on error.
410411
*/
411412
int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
412413
struct notifier_block *n)

0 commit comments

Comments
 (0)