lkml.org 
[lkml]   [2019]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] notifiers: double register detection
Date
By design notifiers can be registerd once only,
2nd register attempt called by mistake silently corrupts notifiers list.

Proposed check cannot prevent described problem,
however it allows to detect its reason quickly without coredump analyze.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
kernel/notifier.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/notifier.c b/kernel/notifier.c
index 6196af8a8223..bfc95b3e4235 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -22,6 +22,7 @@ static int notifier_chain_register(struct notifier_block **nl,
struct notifier_block *n)
{
while ((*nl) != NULL) {
+ WARN_ONCE(((*nl) == n), "double register detected");
if (n->priority > (*nl)->priority)
break;
nl = &((*nl)->next);
--
2.17.1
\
 
 \ /
  Last update: 2019-03-12 09:06    [W:0.036 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site