From: Christoph Hellwig <hch@infradead.org>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/3] fs: move path_put on failure out of ->follow_link
Date: Mon, 18 Jun 2012 10:47:03 -0400 [thread overview]
Message-ID: <20120618144755.325876713@bombadil.infradead.org> (raw)
In-Reply-To: 20120618144702.856266417@bombadil.infradead.org
[-- Attachment #1: fs-follow_link-dont-put --]
[-- Type: text/plain, Size: 2010 bytes --]
Currently the non-nd_set_link based versions of ->follow_link are expected
to do a path_put(&nd->path). This calling convention is unexpected,
undocumented and doesn't match what the nd_set_link-based instance do.
Move the path_put out of the only non-nd_set_link based ->follow_link
instance into the caller.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/namei.c | 3 +--
fs/proc/base.c | 12 ++++++++----
2 files changed, 9 insertions(+), 6 deletions(-)
Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c 2012-06-18 12:46:47.560143542 +0200
+++ linux-2.6/fs/namei.c 2012-06-18 12:47:02.424143920 +0200
@@ -615,7 +615,7 @@ follow_link(struct path *link, struct na
*p = dentry->d_inode->i_op->follow_link(dentry, nd);
error = PTR_ERR(*p);
if (IS_ERR(*p))
- goto out_put_link;
+ goto out_put_nd_path;
error = 0;
s = nd_get_link(nd);
@@ -640,7 +640,6 @@ follow_link(struct path *link, struct na
out_put_nd_path:
path_put(&nd->path);
-out_put_link:
path_put(link);
return error;
}
Index: linux-2.6/fs/proc/base.c
===================================================================
--- linux-2.6.orig/fs/proc/base.c 2012-06-18 12:46:47.560143542 +0200
+++ linux-2.6/fs/proc/base.c 2012-06-18 12:47:02.424143920 +0200
@@ -1427,16 +1427,20 @@ static int proc_exe_link(struct dentry *
static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
{
struct inode *inode = dentry->d_inode;
+ struct path path;
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? */
if (!proc_fd_access_allowed(inode))
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:
return ERR_PTR(error);
}
next prev parent reply other threads:[~2012-06-18 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-18 14:47 [PATCH 0/3] make struct nameidata private to namei.c Christoph Hellwig
2012-06-18 14:47 ` Christoph Hellwig [this message]
2012-06-18 14:47 ` [PATCH 2/3] fs: add nd_jump_link Christoph Hellwig
2012-06-18 14:47 ` [PATCH 3/3] fs: make struct nameidata private to namei.c Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120618144755.325876713@bombadil.infradead.org \
--to=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).