namei: simplify failure exits in get_link()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 10 May 2015 14:43:46 +0000 (10:43 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 11 May 2015 02:20:16 +0000 (22:20 -0400)
when cookie is NULL, put_link() is equivalent to path_put(), so
as soon as we'd set last->cookie to NULL, we can bump nd->depth and
let the normal logics in terminate_walk() to take care of cleanups.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index f311f0369e3cd34dc810486d3cff55f158e3ffaf..678aeef854901e8ff890d28d1ea494caaaa22b0d 100644 (file)
@@ -904,27 +904,23 @@ const char *get_link(struct nameidata *nd)
 
        last->link = nd->link;
        last->cookie = NULL;
+       nd->depth++;
 
        cond_resched();
 
        touch_atime(&last->link);
 
        error = security_inode_follow_link(dentry);
-       res = ERR_PTR(error);
        if (error)
-               goto out;
+               return ERR_PTR(error);
 
        nd->last_type = LAST_BIND;
        res = inode->i_link;
        if (!res) {
                res = inode->i_op->follow_link(dentry, &last->cookie);
-               if (IS_ERR(res)) {
-out:
-                       path_put(&last->link);
-                       return res;
-               }
+               if (IS_ERR_OR_NULL(res))
+                       last->cookie = NULL;
        }
-       nd->depth++;
        return res;
 }