Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 315741
b: refs/heads/master
c: b09e786
h: refs/heads/master
i:
  315739: 4904ea3
v: v3
  • Loading branch information
Mikulas Patocka authored and David S. Miller committed Jul 20, 2012
1 parent e29499b commit f1e1626
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 521f549097a79dc55e18c3bc752ef2127ad70ac5
refs/heads/master: b09e786bd1dd66418b69348cb110f3a64764626a
3 changes: 3 additions & 0 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ static void tun_free_netdev(struct net_device *dev)
{
struct tun_struct *tun = netdev_priv(dev);

BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED, &tun->socket.flags));

sk_release_kernel(tun->socket.sk);
}

Expand Down Expand Up @@ -1115,6 +1117,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
tun->flags = flags;
tun->txflt.count = 0;
tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
set_bit(SOCK_EXTERNALLY_ALLOCATED, &tun->socket.flags);

err = -ENOMEM;
sk = sk_alloc(&init_net, AF_UNSPEC, GFP_KERNEL, &tun_proto);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct net;
#define SOCK_NOSPACE 2
#define SOCK_PASSCRED 3
#define SOCK_PASSSEC 4
#define SOCK_EXTERNALLY_ALLOCATED 5

#ifndef ARCH_HAS_SOCKET_TYPES
/**
Expand Down
3 changes: 3 additions & 0 deletions trunk/net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ void sock_release(struct socket *sock)
if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
printk(KERN_ERR "sock_release: fasync list not empty!\n");

if (test_bit(SOCK_EXTERNALLY_ALLOCATED, &sock->flags))
return;

this_cpu_sub(sockets_in_use, 1);
if (!sock->file) {
iput(SOCK_INODE(sock));
Expand Down

0 comments on commit f1e1626

Please sign in to comment.