diff options
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r-- | drivers/net/tun.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index d83ccb8c982b..811d3517fce0 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -1322,21 +1322,22 @@ static int tun_chr_open(struct inode *inode, struct file * file) | |||
1322 | static int tun_chr_close(struct inode *inode, struct file *file) | 1322 | static int tun_chr_close(struct inode *inode, struct file *file) |
1323 | { | 1323 | { |
1324 | struct tun_file *tfile = file->private_data; | 1324 | struct tun_file *tfile = file->private_data; |
1325 | struct tun_struct *tun = __tun_get(tfile); | 1325 | struct tun_struct *tun; |
1326 | 1326 | ||
1327 | 1327 | ||
1328 | rtnl_lock(); | ||
1329 | tun = __tun_get(tfile); | ||
1328 | if (tun) { | 1330 | if (tun) { |
1329 | DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); | 1331 | DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); |
1330 | 1332 | ||
1331 | rtnl_lock(); | ||
1332 | __tun_detach(tun); | 1333 | __tun_detach(tun); |
1333 | 1334 | ||
1334 | /* If desireable, unregister the netdevice. */ | 1335 | /* If desireable, unregister the netdevice. */ |
1335 | if (!(tun->flags & TUN_PERSIST)) | 1336 | if (!(tun->flags & TUN_PERSIST)) |
1336 | unregister_netdevice(tun->dev); | 1337 | unregister_netdevice(tun->dev); |
1337 | 1338 | ||
1338 | rtnl_unlock(); | ||
1339 | } | 1339 | } |
1340 | rtnl_unlock(); | ||
1340 | 1341 | ||
1341 | tun = tfile->tun; | 1342 | tun = tfile->tun; |
1342 | if (tun) | 1343 | if (tun) |