* [PATCH] netiucv: Hold rtnl between name allocation and device registration.
@ 2013-06-13 13:09 Benjamin Poirier
2013-06-14 0:41 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Poirier @ 2013-06-13 13:09 UTC (permalink / raw)
To: linux-s390
Cc: netdev, Ursula Braun, linux390, Frank Blaschka,
Martin Schwidefsky, Heiko Carstens, Cornelia Huck, linux-kernel
fixes a race condition between concurrent initializations of netiucv devices
that try to use the same name.
sysfs: cannot create duplicate filename '/devices/iucv/netiucv2'
[...]
Call Trace:
([<00000000002edea4>] sysfs_add_one+0xb0/0xdc)
[<00000000002eecd4>] create_dir+0x80/0xfc
[<00000000002eee38>] sysfs_create_dir+0xe8/0x118
[<00000000003835a8>] kobject_add_internal+0x120/0x2d0
[<00000000003839d6>] kobject_add+0x62/0x9c
[<00000000003d9564>] device_add+0xcc/0x510
[<000003e00212c7b4>] netiucv_register_device+0xc0/0x1ec [netiucv]
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Tested-by: Ursula Braun <braunu@de.ibm.com>
---
drivers/s390/net/netiucv.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 4ffa66c..9ca3996 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -2040,6 +2040,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
netiucv_setup_netdevice);
if (!dev)
return NULL;
+ rtnl_lock();
if (dev_alloc_name(dev, dev->name) < 0)
goto out_netdev;
@@ -2061,6 +2062,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
out_fsm:
kfree_fsm(privptr->fsm);
out_netdev:
+ rtnl_unlock();
free_netdev(dev);
return NULL;
}
@@ -2100,6 +2102,7 @@ static ssize_t conn_write(struct device_driver *drv,
rc = netiucv_register_device(dev);
if (rc) {
+ rtnl_unlock();
IUCV_DBF_TEXT_(setup, 2,
"ret %d from netiucv_register_device\n", rc);
goto out_free_ndev;
@@ -2109,7 +2112,8 @@ static ssize_t conn_write(struct device_driver *drv,
priv = netdev_priv(dev);
SET_NETDEV_DEV(dev, priv->dev);
- rc = register_netdev(dev);
+ rc = register_netdevice(dev);
+ rtnl_unlock();
if (rc)
goto out_unreg;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] netiucv: Hold rtnl between name allocation and device registration.
2013-06-13 13:09 [PATCH] netiucv: Hold rtnl between name allocation and device registration Benjamin Poirier
@ 2013-06-14 0:41 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-06-14 0:41 UTC (permalink / raw)
To: bpoirier
Cc: linux-s390, netdev, ursula.braun, linux390, blaschka, schwidefsky,
heiko.carstens, cornelia.huck, linux-kernel
From: Benjamin Poirier <bpoirier@suse.de>
Date: Thu, 13 Jun 2013 09:09:47 -0400
> fixes a race condition between concurrent initializations of netiucv devices
> that try to use the same name.
>
> sysfs: cannot create duplicate filename '/devices/iucv/netiucv2'
> [...]
> Call Trace:
> ([<00000000002edea4>] sysfs_add_one+0xb0/0xdc)
> [<00000000002eecd4>] create_dir+0x80/0xfc
> [<00000000002eee38>] sysfs_create_dir+0xe8/0x118
> [<00000000003835a8>] kobject_add_internal+0x120/0x2d0
> [<00000000003839d6>] kobject_add+0x62/0x9c
> [<00000000003d9564>] device_add+0xcc/0x510
> [<000003e00212c7b4>] netiucv_register_device+0xc0/0x1ec [netiucv]
>
> Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
> Tested-by: Ursula Braun <braunu@de.ibm.com>
Yes as dev_alloc_name() must be invoked under RTNL or dev_base_lock, this
fix is correct.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-14 0:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 13:09 [PATCH] netiucv: Hold rtnl between name allocation and device registration Benjamin Poirier
2013-06-14 0:41 ` David 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).