diff options
-rw-r--r-- | drivers/net/tun.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 11a0ba47b677..b393536012fb 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -1324,20 +1324,22 @@ static int tun_chr_close(struct inode *inode, struct file *file) | |||
1324 | struct tun_file *tfile = file->private_data; | 1324 | struct tun_file *tfile = file->private_data; |
1325 | struct tun_struct *tun; | 1325 | struct tun_struct *tun; |
1326 | 1326 | ||
1327 | |||
1328 | rtnl_lock(); | ||
1329 | tun = __tun_get(tfile); | 1327 | tun = __tun_get(tfile); |
1330 | if (tun) { | 1328 | if (tun) { |
1331 | DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); | 1329 | struct net_device *dev = tun->dev; |
1330 | |||
1331 | DBG(KERN_INFO "%s: tun_chr_close\n", dev->name); | ||
1332 | 1332 | ||
1333 | __tun_detach(tun); | 1333 | __tun_detach(tun); |
1334 | 1334 | ||
1335 | /* If desireable, unregister the netdevice. */ | 1335 | /* If desireable, unregister the netdevice. */ |
1336 | if (!(tun->flags & TUN_PERSIST)) | 1336 | if (!(tun->flags & TUN_PERSIST)) { |
1337 | unregister_netdevice(tun->dev); | 1337 | rtnl_lock(); |
1338 | 1338 | if (dev->reg_state == NETREG_REGISTERED) | |
1339 | unregister_netdevice(dev); | ||
1340 | rtnl_unlock(); | ||
1341 | } | ||
1339 | } | 1342 | } |
1340 | rtnl_unlock(); | ||
1341 | 1343 | ||
1342 | tun = tfile->tun; | 1344 | tun = tfile->tun; |
1343 | if (tun) | 1345 | if (tun) |