aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 901551c8ca0e..a82b32b40131 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -44,6 +44,7 @@
44#include <linux/kernel.h> 44#include <linux/kernel.h>
45#include <linux/major.h> 45#include <linux/major.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/smp_lock.h>
47#include <linux/poll.h> 48#include <linux/poll.h>
48#include <linux/fcntl.h> 49#include <linux/fcntl.h>
49#include <linux/init.h> 50#include <linux/init.h>
@@ -938,22 +939,26 @@ static int tun_chr_fasync(int fd, struct file *file, int on)
938 939
939 DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on); 940 DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on);
940 941
942 lock_kernel();
941 if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0) 943 if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0)
942 return ret; 944 goto out;
943 945
944 if (on) { 946 if (on) {
945 ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0); 947 ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0);
946 if (ret) 948 if (ret)
947 return ret; 949 goto out;
948 tun->flags |= TUN_FASYNC; 950 tun->flags |= TUN_FASYNC;
949 } else 951 } else
950 tun->flags &= ~TUN_FASYNC; 952 tun->flags &= ~TUN_FASYNC;
951 953 ret = 0;
952 return 0; 954out:
955 unlock_kernel();
956 return ret;
953} 957}
954 958
955static int tun_chr_open(struct inode *inode, struct file * file) 959static int tun_chr_open(struct inode *inode, struct file * file)
956{ 960{
961 cycle_kernel_lock();
957 DBG1(KERN_INFO "tunX: tun_chr_open\n"); 962 DBG1(KERN_INFO "tunX: tun_chr_open\n");
958 file->private_data = NULL; 963 file->private_data = NULL;
959 return 0; 964 return 0;