lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1562728152-30341-1-git-send-email-nixiaoming@huawei.com>
Date:   Wed, 10 Jul 2019 11:09:12 +0800
From:   Xiaoming Ni <nixiaoming@...wei.com>
To:     <adobriyan@...il.com>, <akpm@...ux-foundation.org>,
        <anna.schumaker@...app.com>, <arjan@...ux.intel.com>,
        <bfields@...ldses.org>, <chuck.lever@...cle.com>,
        <davem@...emloft.net>, <gregkh@...uxfoundation.org>,
        <jlayton@...nel.org>, <luto@...nel.org>, <mingo@...nel.org>,
        <Nadia.Derbey@...l.net>, <paulmck@...ux.vnet.ibm.com>,
        <semen.protsenko@...aro.org>, <stable@...nel.org>,
        <stern@...land.harvard.edu>, <tglx@...utronix.de>,
        <torvalds@...ux-foundation.org>, <trond.myklebust@...merspace.com>,
        <viresh.kumar@...aro.org>, <vvs@...tuozzo.com>
CC:     <alex.huangjianhui@...wei.com>, <dylix.dailei@...wei.com>,
        <nixiaoming@...wei.com>, <linux-kernel@...r.kernel.org>,
        <linux-nfs@...r.kernel.org>, <netdev@...r.kernel.org>
Subject: [PATCH v3 2/3] kernel/notifier.c: remove notifier_chain_cond_register()

The only difference between notifier_chain_cond_register() and
notifier_chain_register() is the lack of warning hints for duplicate
registrations.
Consider using notifier_chain_register() instead of
notifier_chain_cond_register() to avoid duplicate code

Signed-off-by: Xiaoming Ni <nixiaoming@...wei.com>
---
 kernel/notifier.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/kernel/notifier.c b/kernel/notifier.c
index 30bedb8..e3d221f 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -36,21 +36,6 @@ static int notifier_chain_register(struct notifier_block **nl,
 	return 0;
 }
 
-static int notifier_chain_cond_register(struct notifier_block **nl,
-		struct notifier_block *n)
-{
-	while ((*nl) != NULL) {
-		if ((*nl) == n)
-			return 0;
-		if (n->priority > (*nl)->priority)
-			break;
-		nl = &((*nl)->next);
-	}
-	n->next = *nl;
-	rcu_assign_pointer(*nl, n);
-	return 0;
-}
-
 static int notifier_chain_unregister(struct notifier_block **nl,
 		struct notifier_block *n)
 {
@@ -252,7 +237,7 @@ int blocking_notifier_chain_cond_register(struct blocking_notifier_head *nh,
 	int ret;
 
 	down_write(&nh->rwsem);
-	ret = notifier_chain_cond_register(&nh->head, n);
+	ret = notifier_chain_register(&nh->head, n);
 	up_write(&nh->rwsem);
 	return ret;
 }
-- 
1.8.5.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ