diff options
author | Benjamin Poirier <bpoirier@suse.de> | 2013-06-13 09:09:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-13 20:41:18 -0400 |
commit | aaf9522d62d18626a60f7f2080671d853d9e8681 (patch) | |
tree | b2dd6cacffe0f504e2ab6f4dcc7bfd16208ae13b | |
parent | c9bfbb31af7c8428267b34eb9706a621ac219a28 (diff) |
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: Benjamin Poirier <bpoirier@suse.de>
Tested-by: Ursula Braun <braunu@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/s390/net/netiucv.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index 4ffa66c87ea5..9ca3996f65b2 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) | |||
2040 | netiucv_setup_netdevice); | 2040 | netiucv_setup_netdevice); |
2041 | if (!dev) | 2041 | if (!dev) |
2042 | return NULL; | 2042 | return NULL; |
2043 | rtnl_lock(); | ||
2043 | if (dev_alloc_name(dev, dev->name) < 0) | 2044 | if (dev_alloc_name(dev, dev->name) < 0) |
2044 | goto out_netdev; | 2045 | goto out_netdev; |
2045 | 2046 | ||
@@ -2061,6 +2062,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata) | |||
2061 | out_fsm: | 2062 | out_fsm: |
2062 | kfree_fsm(privptr->fsm); | 2063 | kfree_fsm(privptr->fsm); |
2063 | out_netdev: | 2064 | out_netdev: |
2065 | rtnl_unlock(); | ||
2064 | free_netdev(dev); | 2066 | free_netdev(dev); |
2065 | return NULL; | 2067 | return NULL; |
2066 | } | 2068 | } |
@@ -2100,6 +2102,7 @@ static ssize_t conn_write(struct device_driver *drv, | |||
2100 | 2102 | ||
2101 | rc = netiucv_register_device(dev); | 2103 | rc = netiucv_register_device(dev); |
2102 | if (rc) { | 2104 | if (rc) { |
2105 | rtnl_unlock(); | ||
2103 | IUCV_DBF_TEXT_(setup, 2, | 2106 | IUCV_DBF_TEXT_(setup, 2, |
2104 | "ret %d from netiucv_register_device\n", rc); | 2107 | "ret %d from netiucv_register_device\n", rc); |
2105 | goto out_free_ndev; | 2108 | goto out_free_ndev; |
@@ -2109,7 +2112,8 @@ static ssize_t conn_write(struct device_driver *drv, | |||
2109 | priv = netdev_priv(dev); | 2112 | priv = netdev_priv(dev); |
2110 | SET_NETDEV_DEV(dev, priv->dev); | 2113 | SET_NETDEV_DEV(dev, priv->dev); |
2111 | 2114 | ||
2112 | rc = register_netdev(dev); | 2115 | rc = register_netdevice(dev); |
2116 | rtnl_unlock(); | ||
2113 | if (rc) | 2117 | if (rc) |
2114 | goto out_unreg; | 2118 | goto out_unreg; |
2115 | 2119 | ||