diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-01 14:26:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-01 14:26:51 -0400 |
commit | d65f5c5803d9cd6fa0b540a0dddf956be671bc36 (patch) | |
tree | d8b7e7197bd126ce857c9a368dd7573b531cb22f /drivers/mtd | |
parent | a8086ad803fc4d251edb9a49838bf99c7fdfb44f (diff) | |
parent | 8d66bf5481002b0960aa49aed0987c73f5d7816c (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
[PATCH] pass struct path * to do_add_mount()
[PATCH] switch mtd and dm-table to lookup_bdev()
[patch 3/4] vfs: remove unused nameidata argument of may_create()
[PATCH] devpts: switch to IDA
[PATCH 2/2] proc: switch inode number allocation to IDA
[PATCH 1/2] proc: fix inode number bogorithmetic
[PATCH] fix bdev leak in block_dev.c do_open()
[PATCH] fix races and leaks in vfs_quota_on() users
[PATCH] clean dup2() up a bit
[PATCH] merge locate_fd() and get_unused_fd()
[PATCH] ipv4_static_sysctl_init() should be under CONFIG_SYSCTL
Re: BUG at security/selinux/avc.c:883 (was: Re: linux-next: Tree
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdsuper.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index 28cc6787a800..9b6af7e74a65 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c | |||
@@ -125,7 +125,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags, | |||
125 | int (*fill_super)(struct super_block *, void *, int), | 125 | int (*fill_super)(struct super_block *, void *, int), |
126 | struct vfsmount *mnt) | 126 | struct vfsmount *mnt) |
127 | { | 127 | { |
128 | struct nameidata nd; | 128 | struct block_device *bdev; |
129 | int mtdnr, ret; | 129 | int mtdnr, ret; |
130 | 130 | ||
131 | if (!dev_name) | 131 | if (!dev_name) |
@@ -181,29 +181,20 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags, | |||
181 | /* try the old way - the hack where we allowed users to mount | 181 | /* try the old way - the hack where we allowed users to mount |
182 | * /dev/mtdblock$(n) but didn't actually _use_ the blockdev | 182 | * /dev/mtdblock$(n) but didn't actually _use_ the blockdev |
183 | */ | 183 | */ |
184 | ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 184 | bdev = lookup_bdev(dev_name); |
185 | 185 | if (IS_ERR(bdev)) { | |
186 | DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", | 186 | ret = PTR_ERR(bdev); |
187 | ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL); | 187 | DEBUG(1, "MTDSB: lookup_bdev() returned %d\n", ret); |
188 | |||
189 | if (ret) | ||
190 | return ret; | 188 | return ret; |
191 | |||
192 | ret = -EINVAL; | ||
193 | |||
194 | if (!S_ISBLK(nd.path.dentry->d_inode->i_mode)) | ||
195 | goto out; | ||
196 | |||
197 | if (nd.path.mnt->mnt_flags & MNT_NODEV) { | ||
198 | ret = -EACCES; | ||
199 | goto out; | ||
200 | } | 189 | } |
190 | DEBUG(1, "MTDSB: lookup_bdev() returned 0\n"); | ||
201 | 191 | ||
202 | if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR) | 192 | ret = -EINVAL; |
193 | if (MAJOR(bdev->bd_dev) != MTD_BLOCK_MAJOR) | ||
203 | goto not_an_MTD_device; | 194 | goto not_an_MTD_device; |
204 | 195 | ||
205 | mtdnr = iminor(nd.path.dentry->d_inode); | 196 | mtdnr = MINOR(bdev->bd_dev); |
206 | path_put(&nd.path); | 197 | bdput(bdev); |
207 | 198 | ||
208 | return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, | 199 | return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, |
209 | mnt); | 200 | mnt); |
@@ -213,10 +204,8 @@ not_an_MTD_device: | |||
213 | printk(KERN_NOTICE | 204 | printk(KERN_NOTICE |
214 | "MTD: Attempt to mount non-MTD device \"%s\"\n", | 205 | "MTD: Attempt to mount non-MTD device \"%s\"\n", |
215 | dev_name); | 206 | dev_name); |
216 | out: | 207 | bdput(bdev); |
217 | path_put(&nd.path); | ||
218 | return ret; | 208 | return ret; |
219 | |||
220 | } | 209 | } |
221 | 210 | ||
222 | EXPORT_SYMBOL_GPL(get_sb_mtd); | 211 | EXPORT_SYMBOL_GPL(get_sb_mtd); |