summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}