|
@@ -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);
|
|
|
}
|
|
|
|
|
@@ -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);
|