Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288443
b: refs/heads/master
c: 1ab5ecb
h: refs/heads/master
i:
  288441: bcfd419
  288439: 3fb322a
v: v3
  • Loading branch information
Stanislav Kinsbursky authored and David S. Miller committed Mar 13, 2012
1 parent f978049 commit 97e8795
Show file tree
Hide file tree
Showing 2 changed files with 13 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: de5c37414af10ac9305d4a3e9c1468347ca3ccaa
refs/heads/master: 1ab5ecb90cb6a3df1476e052f76a6e8f6511cb3d
15 changes: 12 additions & 3 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static void tun_free_netdev(struct net_device *dev)
{
struct tun_struct *tun = netdev_priv(dev);

sock_put(tun->socket.sk);
sk_release_kernel(tun->socket.sk);
}

/* Net device open. */
Expand Down Expand Up @@ -980,10 +980,18 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
return ret;
}

static int tun_release(struct socket *sock)
{
if (sock->sk)
sock_put(sock->sk);
return 0;
}

/* Ops structure to mimic raw sockets with tun */
static const struct proto_ops tun_socket_ops = {
.sendmsg = tun_sendmsg,
.recvmsg = tun_recvmsg,
.release = tun_release,
};

static struct proto tun_proto = {
Expand Down Expand Up @@ -1110,10 +1118,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr);

err = -ENOMEM;
sk = sk_alloc(net, AF_UNSPEC, GFP_KERNEL, &tun_proto);
sk = sk_alloc(&init_net, AF_UNSPEC, GFP_KERNEL, &tun_proto);
if (!sk)
goto err_free_dev;

sk_change_net(sk, net);
tun->socket.wq = &tun->wq;
init_waitqueue_head(&tun->wq.wait);
tun->socket.ops = &tun_socket_ops;
Expand Down Expand Up @@ -1174,7 +1183,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
return 0;

err_free_sk:
sock_put(sk);
tun_free_netdev(dev);
err_free_dev:
free_netdev(dev);
failed:
Expand Down

0 comments on commit 97e8795

Please sign in to comment.