aboutsummaryrefslogtreecommitdiff
path: root/fs/fat
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2010-01-12 03:32:24 +0900
committerOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2010-01-12 03:47:25 +0900
commit8045e2985012bdb95d832dfbcceae1815880a6ed (patch)
tree513a853a81eee10f86047b681bf52132592b36b9 /fs/fat
parent3c8ad49b015eb115fbd6982f56d530f53cf57f84 (diff)
fat: Fix vfat_lookup()
After d_find_alias(), vfat_lookup() checks !(->d_flags & DCACHE_DISCONNECTED) without IS_ROOT(). This means it hits non-anonymous but disconnected dentry. (NOTE: d_splice_alias() doesn't clear DCACHE_DISCONNECTED) But, vfat_lookup() has interest to alias if it was non-anonymous. So, this adds vfat_d_anon_disconn() helper to check it correctly. Another bug is refcnt leak. It needs dput() for uninterested alias. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/namei_vfat.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index f565f24019b..411c192a05f 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -701,6 +701,15 @@ static int vfat_find(struct inode *dir, struct qstr *qname,
return fat_search_long(dir, qname->name, len, sinfo);
}
+/*
+ * (nfsd's) anonymous disconnected dentry?
+ * NOTE: !IS_ROOT() is not anonymous (I.e. d_splice_alias() did the job).
+ */
+static int vfat_d_anon_disconn(struct dentry *dentry)
+{
+ return IS_ROOT(dentry) && (dentry->d_flags & DCACHE_DISCONNECTED);
+}
+
static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
@@ -729,11 +738,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
}
alias = d_find_alias(inode);
- if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) {
+ if (alias && !vfat_d_anon_disconn(alias)) {
/*
- * This inode has non DCACHE_DISCONNECTED dentry. This
- * means, the user did ->lookup() by an another name
- * (longname vs 8.3 alias of it) in past.
+ * This inode has non anonymous-DCACHE_DISCONNECTED
+ * dentry. This means, the user did ->lookup() by an
+ * another name (longname vs 8.3 alias of it) in past.
*
* Switch to new one for reason of locality if possible.
*/
@@ -743,7 +752,9 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
iput(inode);
unlock_super(sb);
return alias;
- }
+ } else
+ dput(alias);
+
out:
unlock_super(sb);
dentry->d_op = sb->s_root->d_op;