aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hppfs/hppfs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-18 12:03:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-18 12:03:15 -0400
commitd36c30181c4cf6ead34ae30fa2c777b871225c87 (patch)
tree8a2476c0eb6bb83ed5a8b493d79458d0e114a146 /fs/hppfs/hppfs.c
parenta406721dff91a9a5297d140dbb90327966cf9bc0 (diff)
parent0916a5e45fbd2604a303c8cc18e6b2b7c815e4c9 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: hppfs_lookup(): don't open-code lookup_one_len() hppfs: fix dentry leak cramfs: get_cramfs_inode() returns ERR_PTR() on failure ufs should use d_splice_alias() fix exofs ->get_parent() ceph analog of cifs build_path_from_dentry() race fix cifs: build_path_from_dentry() race fix
Diffstat (limited to 'fs/hppfs/hppfs.c')
-rw-r--r--fs/hppfs/hppfs.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 87ed48e0343d..85c098a499f3 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -139,7 +139,8 @@ static int file_removed(struct dentry *dentry, const char *file)
139static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, 139static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
140 struct nameidata *nd) 140 struct nameidata *nd)
141{ 141{
142 struct dentry *proc_dentry, *new, *parent; 142 struct dentry *proc_dentry, *parent;
143 struct qstr *name = &dentry->d_name;
143 struct inode *inode; 144 struct inode *inode;
144 int err, deleted; 145 int err, deleted;
145 146
@@ -149,23 +150,9 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
149 else if (deleted) 150 else if (deleted)
150 return ERR_PTR(-ENOENT); 151 return ERR_PTR(-ENOENT);
151 152
152 err = -ENOMEM;
153 parent = HPPFS_I(ino)->proc_dentry; 153 parent = HPPFS_I(ino)->proc_dentry;
154 mutex_lock(&parent->d_inode->i_mutex); 154 mutex_lock(&parent->d_inode->i_mutex);
155 proc_dentry = d_lookup(parent, &dentry->d_name); 155 proc_dentry = lookup_one_len(name->name, parent, name->len);
156 if (proc_dentry == NULL) {
157 proc_dentry = d_alloc(parent, &dentry->d_name);
158 if (proc_dentry == NULL) {
159 mutex_unlock(&parent->d_inode->i_mutex);
160 goto out;
161 }
162 new = (*parent->d_inode->i_op->lookup)(parent->d_inode,
163 proc_dentry, NULL);
164 if (new) {
165 dput(proc_dentry);
166 proc_dentry = new;
167 }
168 }
169 mutex_unlock(&parent->d_inode->i_mutex); 156 mutex_unlock(&parent->d_inode->i_mutex);
170 157
171 if (IS_ERR(proc_dentry)) 158 if (IS_ERR(proc_dentry))
@@ -174,13 +161,11 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
174 err = -ENOMEM; 161 err = -ENOMEM;
175 inode = get_inode(ino->i_sb, proc_dentry); 162 inode = get_inode(ino->i_sb, proc_dentry);
176 if (!inode) 163 if (!inode)
177 goto out_dput; 164 goto out;
178 165
179 d_add(dentry, inode); 166 d_add(dentry, inode);
180 return NULL; 167 return NULL;
181 168
182 out_dput:
183 dput(proc_dentry);
184 out: 169 out:
185 return ERR_PTR(err); 170 return ERR_PTR(err);
186} 171}
@@ -690,8 +675,10 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
690 struct inode *proc_ino = dentry->d_inode; 675 struct inode *proc_ino = dentry->d_inode;
691 struct inode *inode = new_inode(sb); 676 struct inode *inode = new_inode(sb);
692 677
693 if (!inode) 678 if (!inode) {
679 dput(dentry);
694 return ERR_PTR(-ENOMEM); 680 return ERR_PTR(-ENOMEM);
681 }
695 682
696 if (S_ISDIR(dentry->d_inode->i_mode)) { 683 if (S_ISDIR(dentry->d_inode->i_mode)) {
697 inode->i_op = &hppfs_dir_iops; 684 inode->i_op = &hppfs_dir_iops;
@@ -704,7 +691,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
704 inode->i_fop = &hppfs_file_fops; 691 inode->i_fop = &hppfs_file_fops;
705 } 692 }
706 693
707 HPPFS_I(inode)->proc_dentry = dget(dentry); 694 HPPFS_I(inode)->proc_dentry = dentry;
708 695
709 inode->i_uid = proc_ino->i_uid; 696 inode->i_uid = proc_ino->i_uid;
710 inode->i_gid = proc_ino->i_gid; 697 inode->i_gid = proc_ino->i_gid;
@@ -737,7 +724,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
737 sb->s_fs_info = proc_mnt; 724 sb->s_fs_info = proc_mnt;
738 725
739 err = -ENOMEM; 726 err = -ENOMEM;
740 root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root); 727 root_inode = get_inode(sb, dget(proc_mnt->mnt_sb->s_root));
741 if (!root_inode) 728 if (!root_inode)
742 goto out_mntput; 729 goto out_mntput;
743 730