summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHirofumi Ogawa <hirofumi@mail.parknet.co.jp>2002-05-24 20:31:46 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-05-24 20:31:46 -0700
commit79980093177a166328fa77a951217b999b3e8a75 (patch)
treea1a86b6c2b6bd0ea980bbe4b03f0940996af2095
parentbf1c989a47972d15804a9eecb0e2d6276b0178f0 (diff)
[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.
-rw-r--r--fs/msdos/namei.c15
-rw-r--r--fs/vfat/namei.c14
2 files changed, 10 insertions, 19 deletions
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c
index b7fbe8be6b2a..12812cddda8a 100644
--- a/fs/msdos/namei.c
+++ b/fs/msdos/namei.c
@@ -222,22 +222,17 @@ struct dentry *msdos_lookup(struct inode *dir,struct dentry *dentry)
if (res)
goto out;
add:
- if (inode) {
- dentry = d_splice_alias(inode, dentry);
- dentry->d_op = &msdos_dentry_operations;
- } else {
- d_add(dentry, inode);
- dentry = NULL;
- }
res = 0;
+ dentry = d_splice_alias(inode, dentry);
+ if (dentry)
+ dentry->d_op = &msdos_dentry_operations;
out:
if (bh)
fat_brelse(sb, bh);
unlock_kernel();
- if (res)
- return ERR_PTR(res);
- else
+ if (!res)
return dentry;
+ return ERR_PTR(res);
}
/***** Creates a directory entry (name is already formatted). */
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c
index cb72167a90f6..c0e93c2c0925 100644
--- a/fs/vfat/namei.c
+++ b/fs/vfat/namei.c
@@ -1021,16 +1021,12 @@ error:
unlock_kernel();
dentry->d_op = &vfat_dentry_ops[table];
dentry->d_time = dentry->d_parent->d_inode->i_version;
- if (inode) {
- dentry = d_splice_alias(inode, dentry);
- if (dentry) {
- dentry->d_op = &vfat_dentry_ops[table];
- dentry->d_time = dentry->d_parent->d_inode->i_version;
- }
- return dentry;
+ dentry = d_splice_alias(inode, dentry);
+ if (dentry) {
+ dentry->d_op = &vfat_dentry_ops[table];
+ dentry->d_time = dentry->d_parent->d_inode->i_version;
}
- d_add(dentry,inode);
- return NULL;
+ return dentry;
}
int vfat_create(struct inode *dir,struct dentry* dentry,int mode)