diff options
-rw-r--r-- | quicktun.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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; } |