Commit 79980093 authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] Fix the handling of dentry on msdos_lookup() (1/4)

If d_splice_alias() doesn't find the alias dentry, it returns NULL.
Then, msdos_lookup() dereference the NULL, and Oopses. Fixed here.

The vfat_lookup() part is cleanup only.
parent bf1c989a
...@@ -222,22 +222,17 @@ struct dentry *msdos_lookup(struct inode *dir,struct dentry *dentry) ...@@ -222,22 +222,17 @@ struct dentry *msdos_lookup(struct inode *dir,struct dentry *dentry)
if (res) if (res)
goto out; goto out;
add: add:
if (inode) {
dentry = d_splice_alias(inode, dentry);
dentry->d_op = &msdos_dentry_operations;
} else {
d_add(dentry, inode);
dentry = NULL;
}
res = 0; res = 0;
dentry = d_splice_alias(inode, dentry);
if (dentry)
dentry->d_op = &msdos_dentry_operations;
out: out:
if (bh) if (bh)
fat_brelse(sb, bh); fat_brelse(sb, bh);
unlock_kernel(); unlock_kernel();
if (res) if (!res)
return ERR_PTR(res);
else
return dentry; return dentry;
return ERR_PTR(res);
} }
/***** Creates a directory entry (name is already formatted). */ /***** Creates a directory entry (name is already formatted). */
......
...@@ -1021,16 +1021,12 @@ struct dentry *vfat_lookup(struct inode *dir,struct dentry *dentry) ...@@ -1021,16 +1021,12 @@ struct dentry *vfat_lookup(struct inode *dir,struct dentry *dentry)
unlock_kernel(); unlock_kernel();
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;
if (inode) { dentry = d_splice_alias(inode, dentry);
dentry = d_splice_alias(inode, dentry); if (dentry) {
if (dentry) { 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;
}
return dentry;
} }
d_add(dentry,inode); return dentry;
return NULL;
} }
int vfat_create(struct inode *dir,struct dentry* dentry,int mode) int vfat_create(struct inode *dir,struct dentry* dentry,int mode)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment