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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 3 Sep 2014 08:57:44 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Linux Netdev List' <netdev@...r.kernel.org>,
	'David Miller' <davem@...emloft.net>
Subject: [PATCH V2 net-next] core: Simplify logic in dev_load().

The code in dev_load() is convoluted.
Return early and remove the 'no_module' variable.

Signed-off-by: David Laight <david.laight@...lab.com>
---

V2: Added signed-off

Note that this patch will only apply after the one that adds the
check for name[0].

net/core/dev_ioctl.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 84edf16..4b7ab54 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -356,7 +356,6 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
 void dev_load(struct net *net, const char *name)
 {
 	struct net_device *dev;
-	int no_module;
 
 	if (!name[0])
 		return;
@@ -364,15 +363,15 @@ void dev_load(struct net *net, const char *name)
 	rcu_read_lock();
 	dev = dev_get_by_name_rcu(net, name);
 	rcu_read_unlock();
+	if (dev)
+		return;
 
-	no_module = !dev;
-	if (no_module && capable(CAP_NET_ADMIN))
-		no_module = request_module("netdev-%s", name);
-	if (no_module && capable(CAP_SYS_MODULE)) {
-		if (!request_module("%s", name))
-			pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
-				name);
-	}
+	if (capable(CAP_NET_ADMIN) && !request_module("netdev-%s", name))
+		return;
+
+	if (capable(CAP_SYS_MODULE) && !request_module("%s", name))
+		pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
+			name);
 }
 EXPORT_SYMBOL(dev_load);
 
-- 
1.8.1.2



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ