diff --git a/drivers/net/tun.c b/drivers/net/tun.c index aa963c44450a7e866eaa1c0670dcf36c5f3c147b..a36b56f0940bd9b2718c3ff522c1b6f2c5bc972e 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -488,8 +488,6 @@ static int tun_attach(struct tun_struct *tun, struct file *file) err = -EINVAL; if (rtnl_dereference(tfile->tun)) goto out; - if (tfile->detached && tun != tfile->detached) - goto out; err = -EBUSY; if (!(tun->flags & TUN_TAP_MQ) && tun->numqueues == 1) @@ -1543,6 +1541,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) struct net_device *dev; int err; + if (tfile->detached) + return -EINVAL; + dev = __dev_get_by_name(net, ifr->ifr_name); if (dev) { if (ifr->ifr_flags & IFF_TUN_EXCL)