summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-04-15 00:35:15 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-04-15 00:35:15 +0200
commit0b8e84d2d24653d51847d1d6b4a206976f64b4f1 (patch)
tree48d39c812e0f1b0b3002b184f3fd5d8ab69abee1
parent3123c2f931cec247156c08dcd1661cb407808177 (diff)
downloadmodquicktun-0b8e84d2d24653d51847d1d6b4a206976f64b4f1.tar
modquicktun-0b8e84d2d24653d51847d1d6b4a206976f64b4f1.zip
Lock correctly on device deletion
-rw-r--r--quicktun.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/quicktun.c b/quicktun.c
index 3e2e628..44b7a7e 100644
--- a/quicktun.c
+++ b/quicktun.c
@@ -326,29 +326,32 @@ static int quicktun_cmd_delete_device(struct sk_buff *skb, struct genl_info *inf
name = nla_data(info->attrs[QUICKTUN_A_IFNAME]);
- dev = dev_get_by_name(net, name);
- if (!dev)
- return -EINVAL;
+ rtnl_lock();
+
+ dev = __dev_get_by_name(net, name);
+ if (!dev) {
+ err = -EINVAL;
+ goto err_unlock;
+ }
if (dev->netdev_ops != &quicktun_ethernet_netdev_ops && dev->netdev_ops != &quicktun_ip_netdev_ops) {
err = -EINVAL;
- goto err;
+ goto err_unlock;
}
tun = netdev_priv(dev);
sock = tun->sock;
- rtnl_lock();
- dev_put(dev);
unregister_netdevice(dev);
+
rtnl_unlock();
sock_release(sock);
return 0;
-err:
- dev_put(dev);
+err_unlock:
+ rtnl_unlock();
return err;
}