diff --git a/drivers/net/tun.c b/drivers/net/tun.c index a1b0697..4c5ae95 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -155,6 +155,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file) err = 0; tfile->tun = tun; tun->tfile = tfile; + tun->sk->sk_sleep = &tfile->read_wait; dev_hold(tun->dev); atomic_inc(&tfile->count); @@ -173,6 +174,8 @@ static void __tun_detach(struct tun_struct *tun) tun->tfile = NULL; netif_tx_unlock_bh(tun->dev); + tun->sk->sk_sleep = NULL; + /* Drop read queue */ skb_queue_purge(&tun->readq); @@ -861,7 +864,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) struct sock *sk; struct tun_struct *tun; struct net_device *dev; - struct tun_file *tfile = file->private_data; int err; dev = __dev_get_by_name(net, ifr->ifr_name); @@ -925,7 +927,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) sk->sk_write_space = tun_sock_write_space; sk->sk_destruct = tun_sock_destruct; sk->sk_sndbuf = INT_MAX; - sk->sk_sleep = &tfile->read_wait; tun->sk = sk; container_of(sk, struct tun_sock, sk)->tun = tun;