netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init_netdev missing locking
@ 2003-10-15 18:05 Randy.Dunlap
  2003-10-16  5:33 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Randy.Dunlap @ 2003-10-15 18:05 UTC (permalink / raw)
  To: netdev; +Cc: davem


It looks like the call to dev_alloc_name() in init_netdev()
isn't protected by the required locking.
This patch adds rtnl_lock/unlock around the call to dev_alloc_name().

Comments?  or please apply.

--
~Randy


description:	add required locking to init_netdev()'s call to
		dev_alloc_name()
patch_name:	netinit_alloc_lock.patch
product_versions: Linux 2.6.0-test7
maintainer:	davem@redhat.com
author:		Randy.Dunlap <rddunlap@osdl.org>
patch_version:	2003-10-15.10:55:51

diffstat:=
 drivers/net/net_init.c |    3 +++
 1 files changed, 3 insertions(+)

diff -Naurp ./drivers/net/net_init.c~dev_alloc_lock ./drivers/net/net_init.c
--- ./drivers/net/net_init.c~dev_alloc_lock	2003-10-15 10:53:02.000000000 -0700
+++ ./drivers/net/net_init.c	2003-10-15 10:53:34.000000000 -0700
@@ -148,11 +148,14 @@ static struct net_device *init_netdev(st
 	 
 	if (dev->name[0] == '\0' || dev->name[0] == ' ') {
 		strcpy(dev->name, mask);
+		rtnl_lock();
 		if (dev_alloc_name(dev, mask)<0) {
+			rtnl_unlock();
 			if (new_device)
 				kfree(dev);
 			return NULL;
 		}
+		rtnl_unlock();
 	}
 
 	netdev_boot_setup_check(dev);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] init_netdev missing locking
  2003-10-15 18:05 [PATCH] init_netdev missing locking Randy.Dunlap
@ 2003-10-16  5:33 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-10-16  5:33 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: netdev

On Wed, 15 Oct 2003 11:05:20 -0700
"Randy.Dunlap" <rddunlap@osdl.org> wrote:

> It looks like the call to dev_alloc_name() in init_netdev()
> isn't protected by the required locking.
> This patch adds rtnl_lock/unlock around the call to dev_alloc_name().
> 
> Comments?  or please apply.

Your fix is correct, so I've applied it.  Stephen is working to
deprecate the one thing that uses this function (init_etherdev()).

Please in the future properly root your patch, I had to fix this
one up before my automated scripts would eat it :)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-16  5:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-15 18:05 [PATCH] init_netdev missing locking Randy.Dunlap
2003-10-16  5:33 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).