Commit aaf9522d authored by Benjamin Poirier's avatar Benjamin Poirier Committed by David S. Miller

netiucv: Hold rtnl between name allocation and device registration.

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: default avatarBenjamin Poirier <bpoirier@suse.de>
Tested-by: default avatarUrsula Braun <braunu@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c9bfbb31
...@@ -2040,6 +2040,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata) ...@@ -2040,6 +2040,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
netiucv_setup_netdevice); netiucv_setup_netdevice);
if (!dev) if (!dev)
return NULL; return NULL;
rtnl_lock();
if (dev_alloc_name(dev, dev->name) < 0) if (dev_alloc_name(dev, dev->name) < 0)
goto out_netdev; goto out_netdev;
...@@ -2061,6 +2062,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata) ...@@ -2061,6 +2062,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
out_fsm: out_fsm:
kfree_fsm(privptr->fsm); kfree_fsm(privptr->fsm);
out_netdev: out_netdev:
rtnl_unlock();
free_netdev(dev); free_netdev(dev);
return NULL; return NULL;
} }
...@@ -2100,6 +2102,7 @@ static ssize_t conn_write(struct device_driver *drv, ...@@ -2100,6 +2102,7 @@ static ssize_t conn_write(struct device_driver *drv,
rc = netiucv_register_device(dev); rc = netiucv_register_device(dev);
if (rc) { if (rc) {
rtnl_unlock();
IUCV_DBF_TEXT_(setup, 2, IUCV_DBF_TEXT_(setup, 2,
"ret %d from netiucv_register_device\n", rc); "ret %d from netiucv_register_device\n", rc);
goto out_free_ndev; goto out_free_ndev;
...@@ -2109,7 +2112,8 @@ static ssize_t conn_write(struct device_driver *drv, ...@@ -2109,7 +2112,8 @@ static ssize_t conn_write(struct device_driver *drv,
priv = netdev_priv(dev); priv = netdev_priv(dev);
SET_NETDEV_DEV(dev, priv->dev); SET_NETDEV_DEV(dev, priv->dev);
rc = register_netdev(dev); rc = register_netdevice(dev);
rtnl_unlock();
if (rc) if (rc)
goto out_unreg; goto out_unreg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment