diff options
-rw-r--r-- | drivers/mtd/maps/nettel.c | 3 | ||||
-rw-r--r-- | drivers/mtd/mtdchar.c | 5 | ||||
-rw-r--r-- | drivers/mtd/mtdcore.c | 24 | ||||
-rw-r--r-- | fs/jffs/jffs_fm.c | 3 | ||||
-rw-r--r-- | fs/jffs2/super.c | 7 |
5 files changed, 24 insertions, 18 deletions
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index f9e8e5bcbc33..528e523245c2 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <linux/mtd/cfi.h> | 21 | #include <linux/mtd/cfi.h> |
22 | #include <linux/reboot.h> | 22 | #include <linux/reboot.h> |
23 | #include <linux/err.h> | ||
23 | #include <linux/kdev_t.h> | 24 | #include <linux/kdev_t.h> |
24 | #include <linux/root_dev.h> | 25 | #include <linux/root_dev.h> |
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
@@ -178,7 +179,7 @@ int nettel_eraseconfig(void) | |||
178 | 179 | ||
179 | init_waitqueue_head(&wait_q); | 180 | init_waitqueue_head(&wait_q); |
180 | mtd = get_mtd_device(NULL, 2); | 181 | mtd = get_mtd_device(NULL, 2); |
181 | if (mtd) { | 182 | if (!IS_ERR(mtd)) { |
182 | nettel_erase.mtd = mtd; | 183 | nettel_erase.mtd = mtd; |
183 | nettel_erase.callback = nettel_erasecallback; | 184 | nettel_erase.callback = nettel_erasecallback; |
184 | nettel_erase.callback = NULL; | 185 | nettel_erase.callback = NULL; |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 7c4adc641328..3013d0883b97 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <linux/device.h> | 8 | #include <linux/device.h> |
9 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
10 | #include <linux/err.h> | ||
10 | #include <linux/init.h> | 11 | #include <linux/init.h> |
11 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
@@ -100,8 +101,8 @@ static int mtd_open(struct inode *inode, struct file *file) | |||
100 | 101 | ||
101 | mtd = get_mtd_device(NULL, devnum); | 102 | mtd = get_mtd_device(NULL, devnum); |
102 | 103 | ||
103 | if (!mtd) | 104 | if (IS_ERR(mtd)) |
104 | return -ENODEV; | 105 | return PTR_ERR(mtd); |
105 | 106 | ||
106 | if (MTD_ABSENT == mtd->type) { | 107 | if (MTD_ABSENT == mtd->type) { |
107 | put_mtd_device(mtd); | 108 | put_mtd_device(mtd); |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index f11f55f02413..60f237f91bb2 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -193,14 +193,14 @@ int unregister_mtd_user (struct mtd_notifier *old) | |||
193 | * Given a number and NULL address, return the num'th entry in the device | 193 | * Given a number and NULL address, return the num'th entry in the device |
194 | * table, if any. Given an address and num == -1, search the device table | 194 | * table, if any. Given an address and num == -1, search the device table |
195 | * for a device with that address and return if it's still present. Given | 195 | * for a device with that address and return if it's still present. Given |
196 | * both, return the num'th driver only if its address matches. Return NULL | 196 | * both, return the num'th driver only if its address matches. Return |
197 | * if not. | 197 | * error code if not. |
198 | */ | 198 | */ |
199 | 199 | ||
200 | struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) | 200 | struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) |
201 | { | 201 | { |
202 | struct mtd_info *ret = NULL; | 202 | struct mtd_info *ret = NULL; |
203 | int i; | 203 | int i, err = -ENODEV; |
204 | 204 | ||
205 | mutex_lock(&mtd_table_mutex); | 205 | mutex_lock(&mtd_table_mutex); |
206 | 206 | ||
@@ -217,22 +217,24 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) | |||
217 | if (!ret) | 217 | if (!ret) |
218 | goto out_unlock; | 218 | goto out_unlock; |
219 | 219 | ||
220 | if (!try_module_get(ret->owner)) { | 220 | if (!try_module_get(ret->owner)) |
221 | ret = NULL; | ||
222 | goto out_unlock; | 221 | goto out_unlock; |
223 | } | ||
224 | 222 | ||
225 | if (ret->get_device && ret->get_device(ret)) { | 223 | if (ret->get_device) { |
226 | module_put(ret->owner); | 224 | err = ret->get_device(ret); |
227 | ret = NULL; | 225 | if (err) |
228 | goto out_unlock; | 226 | goto out_put; |
229 | } | 227 | } |
230 | 228 | ||
231 | ret->usecount++; | 229 | ret->usecount++; |
230 | mutex_unlock(&mtd_table_mutex); | ||
231 | return ret; | ||
232 | 232 | ||
233 | out_put: | ||
234 | module_put(ret->owner); | ||
233 | out_unlock: | 235 | out_unlock: |
234 | mutex_unlock(&mtd_table_mutex); | 236 | mutex_unlock(&mtd_table_mutex); |
235 | return ret; | 237 | return ERR_PTR(err); |
236 | } | 238 | } |
237 | 239 | ||
238 | /** | 240 | /** |
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c index 29b68d939bd9..6aab317f56e0 100644 --- a/fs/jffs/jffs_fm.c +++ b/fs/jffs/jffs_fm.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/err.h> | ||
20 | #include <linux/blkdev.h> | 21 | #include <linux/blkdev.h> |
21 | #include <linux/jffs.h> | 22 | #include <linux/jffs.h> |
22 | #include "jffs_fm.h" | 23 | #include "jffs_fm.h" |
@@ -104,7 +105,7 @@ jffs_build_begin(struct jffs_control *c, int unit) | |||
104 | 105 | ||
105 | mtd = get_mtd_device(NULL, unit); | 106 | mtd = get_mtd_device(NULL, unit); |
106 | 107 | ||
107 | if (!mtd) { | 108 | if (IS_ERR(mtd)) { |
108 | kfree(fmc); | 109 | kfree(fmc); |
109 | DJM(no_jffs_fmcontrol--); | 110 | DJM(no_jffs_fmcontrol--); |
110 | return NULL; | 111 | return NULL; |
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index bc4b8106a490..590f60a897c1 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/list.h> | 18 | #include <linux/list.h> |
19 | #include <linux/fs.h> | 19 | #include <linux/fs.h> |
20 | #include <linux/err.h> | ||
20 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
21 | #include <linux/jffs2.h> | 22 | #include <linux/jffs2.h> |
22 | #include <linux/pagemap.h> | 23 | #include <linux/pagemap.h> |
@@ -184,9 +185,9 @@ static int jffs2_get_sb_mtdnr(struct file_system_type *fs_type, | |||
184 | struct mtd_info *mtd; | 185 | struct mtd_info *mtd; |
185 | 186 | ||
186 | mtd = get_mtd_device(NULL, mtdnr); | 187 | mtd = get_mtd_device(NULL, mtdnr); |
187 | if (!mtd) { | 188 | if (IS_ERR(mtd)) { |
188 | D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr)); | 189 | D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr)); |
189 | return -EINVAL; | 190 | return PTR_ERR(mtd); |
190 | } | 191 | } |
191 | 192 | ||
192 | return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); | 193 | return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); |
@@ -221,7 +222,7 @@ static int jffs2_get_sb(struct file_system_type *fs_type, | |||
221 | D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4)); | 222 | D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4)); |
222 | for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) { | 223 | for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) { |
223 | mtd = get_mtd_device(NULL, mtdnr); | 224 | mtd = get_mtd_device(NULL, mtdnr); |
224 | if (mtd) { | 225 | if (!IS_ERR(mtd)) { |
225 | if (!strcmp(mtd->name, dev_name+4)) | 226 | if (!strcmp(mtd->name, dev_name+4)) |
226 | return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); | 227 | return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); |
227 | put_mtd_device(mtd); | 228 | put_mtd_device(mtd); |