Merge branches 'work.misc' and 'work.dcache' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / fs / hostfs / hostfs_kern.c
index 2597b290c2a596c0853761a1f7f776f38ddfbfa0..444c7b1703594403fb88c32efc5ae70af7c72f78 100644 (file)
@@ -610,33 +610,21 @@ static struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
        int err;
 
        inode = hostfs_iget(ino->i_sb);
-       if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
+       if (IS_ERR(inode))
                goto out;
-       }
 
        err = -ENOMEM;
        name = dentry_name(dentry);
-       if (name == NULL)
-               goto out_put;
-
-       err = read_name(inode, name);
-
-       __putname(name);
-       if (err == -ENOENT) {
+       if (name) {
+               err = read_name(inode, name);
+               __putname(name);
+       }
+       if (err) {
                iput(inode);
-               inode = NULL;
+               inode = (err == -ENOENT) ? NULL : ERR_PTR(err);
        }
-       else if (err)
-               goto out_put;
-
-       d_add(dentry, inode);
-       return NULL;
-
- out_put:
-       iput(inode);
  out:
-       return ERR_PTR(err);
+       return d_splice_alias(inode, dentry);
 }
 
 static int hostfs_link(struct dentry *to, struct inode *ino,