aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-14 17:48:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-14 17:48:31 -0400
commitd1794f2c5b5817eb79ccc5e00701ca748d1b073a (patch)
tree5a4c98e694e88a8c82f342d0cc9edb2a4cbbef36 /drivers/mtd
parenta41eebab7537890409ea9dfe0fcda9b5fbdb090d (diff)
parent2fceef397f9880b212a74c418290ce69e7ac00eb (diff)
Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6
* 'bkl-removal' of git://git.lwn.net/linux-2.6: (146 commits) IB/umad: BKL is not needed for ib_umad_open() IB/uverbs: BKL is not needed for ib_uverbs_open() bf561-coreb: BKL unneeded for open() Call fasync() functions without the BKL snd/PCM: fasync BKL pushdown ipmi: fasync BKL pushdown ecryptfs: fasync BKL pushdown Bluetooth VHCI: fasync BKL pushdown tty_io: fasync BKL pushdown tun: fasync BKL pushdown i2o: fasync BKL pushdown mpt: fasync BKL pushdown Remove BKL from remote_llseek v2 Make FAT users happier by not deadlocking x86-mce: BKL pushdown vmwatchdog: BKL pushdown vmcp: BKL pushdown via-pmu: BKL pushdown uml-random: BKL pushdown uml-mmapper: BKL pushdown ...
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdchar.c22
-rw-r--r--drivers/mtd/ubi/cdev.c7
2 files changed, 22 insertions, 7 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 5d3ac512ce16..129d429cd2da 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/smp_lock.h>
17 18
18#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
19#include <linux/mtd/compatmac.h> 20#include <linux/mtd/compatmac.h>
@@ -86,6 +87,7 @@ static int mtd_open(struct inode *inode, struct file *file)
86{ 87{
87 int minor = iminor(inode); 88 int minor = iminor(inode);
88 int devnum = minor >> 1; 89 int devnum = minor >> 1;
90 int ret = 0;
89 struct mtd_info *mtd; 91 struct mtd_info *mtd;
90 struct mtd_file_info *mfi; 92 struct mtd_file_info *mfi;
91 93
@@ -98,31 +100,39 @@ static int mtd_open(struct inode *inode, struct file *file)
98 if ((file->f_mode & 2) && (minor & 1)) 100 if ((file->f_mode & 2) && (minor & 1))
99 return -EACCES; 101 return -EACCES;
100 102
103 lock_kernel();
101 mtd = get_mtd_device(NULL, devnum); 104 mtd = get_mtd_device(NULL, devnum);
102 105
103 if (IS_ERR(mtd)) 106 if (IS_ERR(mtd)) {
104 return PTR_ERR(mtd); 107 ret = PTR_ERR(mtd);
108 goto out;
109 }
105 110
106 if (MTD_ABSENT == mtd->type) { 111 if (MTD_ABSENT == mtd->type) {
107 put_mtd_device(mtd); 112 put_mtd_device(mtd);
108 return -ENODEV; 113 ret = -ENODEV;
114 goto out;
109 } 115 }
110 116
111 /* You can't open it RW if it's not a writeable device */ 117 /* You can't open it RW if it's not a writeable device */
112 if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { 118 if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
113 put_mtd_device(mtd); 119 put_mtd_device(mtd);
114 return -EACCES; 120 ret = -EACCES;
121 goto out;
115 } 122 }
116 123
117 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); 124 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL);
118 if (!mfi) { 125 if (!mfi) {
119 put_mtd_device(mtd); 126 put_mtd_device(mtd);
120 return -ENOMEM; 127 ret = -ENOMEM;
128 goto out;
121 } 129 }
122 mfi->mtd = mtd; 130 mfi->mtd = mtd;
123 file->private_data = mfi; 131 file->private_data = mfi;
124 132
125 return 0; 133out:
134 unlock_kernel();
135 return ret;
126} /* mtd_open */ 136} /* mtd_open */
127 137
128/*====================================================================*/ 138/*====================================================================*/
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 9d6aae5449b6..89193ba9451e 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -39,6 +39,7 @@
39#include <linux/stat.h> 39#include <linux/stat.h>
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/capability.h> 41#include <linux/capability.h>
42#include <linux/smp_lock.h>
42#include <mtd/ubi-user.h> 43#include <mtd/ubi-user.h>
43#include <asm/uaccess.h> 44#include <asm/uaccess.h>
44#include <asm/div64.h> 45#include <asm/div64.h>
@@ -103,9 +104,12 @@ static int vol_cdev_open(struct inode *inode, struct file *file)
103 struct ubi_volume_desc *desc; 104 struct ubi_volume_desc *desc;
104 int vol_id = iminor(inode) - 1, mode, ubi_num; 105 int vol_id = iminor(inode) - 1, mode, ubi_num;
105 106
107 lock_kernel();
106 ubi_num = ubi_major2num(imajor(inode)); 108 ubi_num = ubi_major2num(imajor(inode));
107 if (ubi_num < 0) 109 if (ubi_num < 0) {
110 unlock_kernel();
108 return ubi_num; 111 return ubi_num;
112 }
109 113
110 if (file->f_mode & FMODE_WRITE) 114 if (file->f_mode & FMODE_WRITE)
111 mode = UBI_READWRITE; 115 mode = UBI_READWRITE;
@@ -115,6 +119,7 @@ static int vol_cdev_open(struct inode *inode, struct file *file)
115 dbg_msg("open volume %d, mode %d", vol_id, mode); 119 dbg_msg("open volume %d, mode %d", vol_id, mode);
116 120
117 desc = ubi_open_volume(ubi_num, vol_id, mode); 121 desc = ubi_open_volume(ubi_num, vol_id, mode);
122 unlock_kernel();
118 if (IS_ERR(desc)) 123 if (IS_ERR(desc))
119 return PTR_ERR(desc); 124 return PTR_ERR(desc);
120 125