summaryrefslogtreecommitdiffstats
path: root/fs/fat/namei_vfat.c
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2008-11-06 21:53:51 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-07 00:41:21 +0100
commit068f5ae05c51d2cee6b31cb3da06775dd83bd348 (patch)
treea5e0d4ddd6f4edcc23ea58d9b86d8edd1ec6e2f8 /fs/fat/namei_vfat.c
parentfat: use fat_detach() in fat_clear_inode() (diff)
downloadlinux-068f5ae05c51d2cee6b31cb3da06775dd83bd348.tar.xz
linux-068f5ae05c51d2cee6b31cb3da06775dd83bd348.zip
vfat: Fix vfat_find() error path in vfat_lookup()
Current vfat_lookup() creates negetive dentry blindly if vfat_find() returned a error. It's wrong. If the error isn't -ENOENT, just return error. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
-rw-r--r--fs/fat/namei_vfat.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 1536bc3ca0f0..419deabfb9be 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -683,7 +683,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
{
struct super_block *sb = dir->i_sb;
struct fat_slot_info sinfo;
- struct inode *inode = NULL;
+ struct inode *inode;
struct dentry *alias;
int err, table;
@@ -693,14 +693,18 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
err = vfat_find(dir, &dentry->d_name, &sinfo);
if (err) {
- table++;
+ if (err == -ENOENT) {
+ table++;
+ inode = NULL;
+ goto out;
+ }
goto error;
}
inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
brelse(sinfo.bh);
if (IS_ERR(inode)) {
- unlock_super(sb);
- return ERR_CAST(inode);
+ err = PTR_ERR(inode);
+ goto error;
}
alias = d_find_alias(inode);
if (alias) {
@@ -713,7 +717,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
}
}
-error:
+out:
unlock_super(sb);
dentry->d_op = &vfat_dentry_ops[table];
dentry->d_time = dentry->d_parent->d_inode->i_version;
@@ -723,6 +727,10 @@ error:
dentry->d_time = dentry->d_parent->d_inode->i_version;
}
return dentry;
+
+error:
+ unlock_super(sb);
+ return ERR_PTR(err);
}
static int vfat_create(struct inode *dir, struct dentry *dentry, int mode,