Commit 15439726 authored by Al Viro's avatar Al Viro

namei: have terminate_walk() do put_link() on everything left

All callers of terminate_walk() are followed by more or less
open-coded eqiuvalent of "do put_link() on everything left
in nd->stack".  Better done in terminate_walk() itself, and
when we go for RCU symlink traversal we'll have to do it
there anyway.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 191d7f73
...@@ -1562,6 +1562,8 @@ static void terminate_walk(struct nameidata *nd) ...@@ -1562,6 +1562,8 @@ static void terminate_walk(struct nameidata *nd)
nd->root.mnt = NULL; nd->root.mnt = NULL;
rcu_read_unlock(); rcu_read_unlock();
} }
while (unlikely(nd->depth))
put_link(nd);
} }
/* /*
...@@ -1856,8 +1858,6 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1856,8 +1858,6 @@ static int link_path_walk(const char *name, struct nameidata *nd)
} }
} }
terminate_walk(nd); terminate_walk(nd);
while (unlikely(nd->depth))
put_link(nd);
return err; return err;
OK: OK:
if (!nd->depth) /* called from path_init(), done */ if (!nd->depth) /* called from path_init(), done */
...@@ -2374,8 +2374,6 @@ mountpoint_last(struct nameidata *nd, struct path *path) ...@@ -2374,8 +2374,6 @@ mountpoint_last(struct nameidata *nd, struct path *path)
error = 0; error = 0;
out: out:
terminate_walk(nd); terminate_walk(nd);
if (nd->depth)
put_link(nd);
return error; return error;
} }
...@@ -2978,8 +2976,6 @@ static int do_last(struct nameidata *nd, ...@@ -2978,8 +2976,6 @@ static int do_last(struct nameidata *nd,
error = handle_dots(nd, nd->last_type); error = handle_dots(nd, nd->last_type);
if (unlikely(error)) { if (unlikely(error)) {
terminate_walk(nd); terminate_walk(nd);
if (nd->depth)
put_link(nd);
return error; return error;
} }
goto finish_open; goto finish_open;
...@@ -3176,8 +3172,6 @@ static int do_last(struct nameidata *nd, ...@@ -3176,8 +3172,6 @@ static int do_last(struct nameidata *nd,
mnt_drop_write(nd->path.mnt); mnt_drop_write(nd->path.mnt);
path_put(&save_parent); path_put(&save_parent);
terminate_walk(nd); terminate_walk(nd);
if (nd->depth)
put_link(nd);
return error; return error;
exit_dput: exit_dput:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment