Commit 408ef013 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

fs: move path_put on failure out of ->follow_link

Currently the non-nd_set_link based versions of ->follow_link are expected
to do a path_put(&nd->path) on failure.  This calling convention is unexpected,
undocumented and doesn't match what the nd_set_link-based instances do.

Move the path_put out of the only non-nd_set_link based ->follow_link
instance into the caller.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent ac481d6c
...@@ -624,7 +624,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p) ...@@ -624,7 +624,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
*p = dentry->d_inode->i_op->follow_link(dentry, nd); *p = dentry->d_inode->i_op->follow_link(dentry, nd);
error = PTR_ERR(*p); error = PTR_ERR(*p);
if (IS_ERR(*p)) if (IS_ERR(*p))
goto out_put_link; goto out_put_nd_path;
error = 0; error = 0;
s = nd_get_link(nd); s = nd_get_link(nd);
...@@ -646,7 +646,6 @@ follow_link(struct path *link, struct nameidata *nd, void **p) ...@@ -646,7 +646,6 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
out_put_nd_path: out_put_nd_path:
path_put(&nd->path); path_put(&nd->path);
out_put_link:
path_put(link); path_put(link);
return error; return error;
} }
......
...@@ -1427,16 +1427,20 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path) ...@@ -1427,16 +1427,20 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct path path;
int error = -EACCES; int error = -EACCES;
/* We don't need a base pointer in the /proc filesystem */
path_put(&nd->path);
/* Are we allowed to snoop on the tasks file descriptors? */ /* Are we allowed to snoop on the tasks file descriptors? */
if (!proc_fd_access_allowed(inode)) if (!proc_fd_access_allowed(inode))
goto out; goto out;
error = PROC_I(inode)->op.proc_get_link(dentry, &nd->path); error = PROC_I(inode)->op.proc_get_link(dentry, &path);
if (error)
goto out;
path_put(&nd->path);
nd->path = path;
return NULL;
out: out:
return ERR_PTR(error); return ERR_PTR(error);
} }
......
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