aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ppp_generic.c2
-rw-r--r--drivers/net/tun.c13
-rw-r--r--drivers/net/wan/cosa.c22
3 files changed, 27 insertions, 10 deletions
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 1f4ca2b54a73..83625fdff3dd 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -39,6 +39,7 @@
39#include <linux/if_arp.h> 39#include <linux/if_arp.h>
40#include <linux/ip.h> 40#include <linux/ip.h>
41#include <linux/tcp.h> 41#include <linux/tcp.h>
42#include <linux/smp_lock.h>
42#include <linux/spinlock.h> 43#include <linux/spinlock.h>
43#include <linux/rwsem.h> 44#include <linux/rwsem.h>
44#include <linux/stddef.h> 45#include <linux/stddef.h>
@@ -353,6 +354,7 @@ static const int npindex_to_ethertype[NUM_NP] = {
353 */ 354 */
354static int ppp_open(struct inode *inode, struct file *file) 355static int ppp_open(struct inode *inode, struct file *file)
355{ 356{
357 cycle_kernel_lock();
356 /* 358 /*
357 * This could (should?) be enforced by the permissions on /dev/ppp. 359 * This could (should?) be enforced by the permissions on /dev/ppp.
358 */ 360 */
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;
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index b0fce1387eaf..5827324e9d9f 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -92,6 +92,7 @@
92#include <linux/spinlock.h> 92#include <linux/spinlock.h>
93#include <linux/mutex.h> 93#include <linux/mutex.h>
94#include <linux/device.h> 94#include <linux/device.h>
95#include <linux/smp_lock.h>
95 96
96#undef COSA_SLOW_IO /* for testing purposes only */ 97#undef COSA_SLOW_IO /* for testing purposes only */
97 98
@@ -970,15 +971,21 @@ static int cosa_open(struct inode *inode, struct file *file)
970 struct channel_data *chan; 971 struct channel_data *chan;
971 unsigned long flags; 972 unsigned long flags;
972 int n; 973 int n;
974 int ret = 0;
973 975
976 lock_kernel();
974 if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS) 977 if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS)
975 >= nr_cards) 978 >= nr_cards) {
976 return -ENODEV; 979 ret = -ENODEV;
980 goto out;
981 }
977 cosa = cosa_cards+n; 982 cosa = cosa_cards+n;
978 983
979 if ((n=iminor(file->f_path.dentry->d_inode) 984 if ((n=iminor(file->f_path.dentry->d_inode)
980 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) 985 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) {
981 return -ENODEV; 986 ret = -ENODEV;
987 goto out;
988 }
982 chan = cosa->chan + n; 989 chan = cosa->chan + n;
983 990
984 file->private_data = chan; 991 file->private_data = chan;
@@ -987,7 +994,8 @@ static int cosa_open(struct inode *inode, struct file *file)
987 994
988 if (chan->usage < 0) { /* in netdev mode */ 995 if (chan->usage < 0) { /* in netdev mode */
989 spin_unlock_irqrestore(&cosa->lock, flags); 996 spin_unlock_irqrestore(&cosa->lock, flags);
990 return -EBUSY; 997 ret = -EBUSY;
998 goto out;
991 } 999 }
992 cosa->usage++; 1000 cosa->usage++;
993 chan->usage++; 1001 chan->usage++;
@@ -996,7 +1004,9 @@ static int cosa_open(struct inode *inode, struct file *file)
996 chan->setup_rx = chrdev_setup_rx; 1004 chan->setup_rx = chrdev_setup_rx;
997 chan->rx_done = chrdev_rx_done; 1005 chan->rx_done = chrdev_rx_done;
998 spin_unlock_irqrestore(&cosa->lock, flags); 1006 spin_unlock_irqrestore(&cosa->lock, flags);
999 return 0; 1007out:
1008 unlock_kernel();
1009 return ret;
1000} 1010}
1001 1011
1002static int cosa_release(struct inode *inode, struct file *file) 1012static int cosa_release(struct inode *inode, struct file *file)