Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 348632
b: refs/heads/master
c: dd38bd8
h: refs/heads/master
v: v3
  • Loading branch information
Jason Wang authored and David S. Miller committed Jan 12, 2013
1 parent 9097cb7 commit 009e3cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7c0c3b1a8a175437991ccc898ed66ec5e4a96208
refs/heads/master: dd38bd853082355641d0034aaf368e13ef2438f8
12 changes: 9 additions & 3 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,10 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
/* Drop read queue */
skb_queue_purge(&tfile->sk.sk_receive_queue);
tun_set_real_num_queues(tun);
} else if (tfile->detached && clean)
} else if (tfile->detached && clean) {
tun = tun_enable_queue(tfile);
sock_put(&tfile->sk);
}

if (clean) {
if (tun && tun->numqueues == 0 && tun->numdisabled == 0 &&
Expand Down Expand Up @@ -478,6 +480,9 @@ static void tun_detach_all(struct net_device *dev)
sock_put(&tfile->sk);
}
BUG_ON(tun->numdisabled != 0);

if (tun->flags & TUN_PERSIST)
module_put(THIS_MODULE);
}

static int tun_attach(struct tun_struct *tun, struct file *file)
Expand Down Expand Up @@ -1874,10 +1879,11 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
/* Disable/Enable persist mode. Keep an extra reference to the
* module to prevent the module being unprobed.
*/
if (arg) {
if (arg && !(tun->flags & TUN_PERSIST)) {
tun->flags |= TUN_PERSIST;
__module_get(THIS_MODULE);
} else {
}
if (!arg && (tun->flags & TUN_PERSIST)) {
tun->flags &= ~TUN_PERSIST;
module_put(THIS_MODULE);
}
Expand Down

0 comments on commit 009e3cb

Please sign in to comment.