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 b9018bfa0a97..eba1271b9735 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -48,6 +48,7 @@
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/major.h> 49#include <linux/major.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <linux/smp_lock.h>
51#include <linux/poll.h> 52#include <linux/poll.h>
52#include <linux/fcntl.h> 53#include <linux/fcntl.h>
53#include <linux/init.h> 54#include <linux/init.h>
@@ -802,22 +803,26 @@ static int tun_chr_fasync(int fd, struct file *file, int on)
802 803
803 DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on); 804 DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on);
804 805
806 lock_kernel();
805 if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0) 807 if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0)
806 return ret; 808 goto out;
807 809
808 if (on) { 810 if (on) {
809 ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0); 811 ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0);
810 if (ret) 812 if (ret)
811 return ret; 813 goto out;
812 tun->flags |= TUN_FASYNC; 814 tun->flags |= TUN_FASYNC;
813 } else 815 } else
814 tun->flags &= ~TUN_FASYNC; 816 tun->flags &= ~TUN_FASYNC;
815 817 ret = 0;
816 return 0; 818out:
819 unlock_kernel();
820 return ret;
817} 821}
818 822
819static int tun_chr_open(struct inode *inode, struct file * file) 823static int tun_chr_open(struct inode *inode, struct file * file)
820{ 824{
825 cycle_kernel_lock();
821 DBG1(KERN_INFO "tunX: tun_chr_open\n"); 826 DBG1(KERN_INFO "tunX: tun_chr_open\n");
822 file->private_data = NULL; 827 file->private_data = NULL;
823 return 0; 828 return 0;