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>
This commit is contained in:
parent
a993b542bb
commit
068f5ae05c
|
@ -683,7 +683,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
|
||||||
{
|
{
|
||||||
struct super_block *sb = dir->i_sb;
|
struct super_block *sb = dir->i_sb;
|
||||||
struct fat_slot_info sinfo;
|
struct fat_slot_info sinfo;
|
||||||
struct inode *inode = NULL;
|
struct inode *inode;
|
||||||
struct dentry *alias;
|
struct dentry *alias;
|
||||||
int err, table;
|
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);
|
err = vfat_find(dir, &dentry->d_name, &sinfo);
|
||||||
if (err) {
|
if (err) {
|
||||||
table++;
|
if (err == -ENOENT) {
|
||||||
|
table++;
|
||||||
|
inode = NULL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
|
inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
|
||||||
brelse(sinfo.bh);
|
brelse(sinfo.bh);
|
||||||
if (IS_ERR(inode)) {
|
if (IS_ERR(inode)) {
|
||||||
unlock_super(sb);
|
err = PTR_ERR(inode);
|
||||||
return ERR_CAST(inode);
|
goto error;
|
||||||
}
|
}
|
||||||
alias = d_find_alias(inode);
|
alias = d_find_alias(inode);
|
||||||
if (alias) {
|
if (alias) {
|
||||||
|
@ -713,7 +717,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
error:
|
out:
|
||||||
unlock_super(sb);
|
unlock_super(sb);
|
||||||
dentry->d_op = &vfat_dentry_ops[table];
|
dentry->d_op = &vfat_dentry_ops[table];
|
||||||
dentry->d_time = dentry->d_parent->d_inode->i_version;
|
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;
|
dentry->d_time = dentry->d_parent->d_inode->i_version;
|
||||||
}
|
}
|
||||||
return dentry;
|
return dentry;
|
||||||
|
|
||||||
|
error:
|
||||||
|
unlock_super(sb);
|
||||||
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfat_create(struct inode *dir, struct dentry *dentry, int mode,
|
static int vfat_create(struct inode *dir, struct dentry *dentry, int mode,
|
||||||
|
|
Loading…
Reference in a new issue