summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-06-09 16:40:37 -0700
committerAl Viro <viro@zeniv.linux.org.uk>2008-06-23 11:52:30 -0400
commit694a1764d657e0f7a9b139bc7269c8d5f5a2534b (patch)
tree754e073cce539c3b6f93e61c3f729bc5959f12f4 /fs
parent20d4fdc1a788e4ca0aaf2422772ba668e7e10839 (diff)
downloadlinux-stable-694a1764d657e0f7a9b139bc7269c8d5f5a2534b.tar.gz
linux-stable-694a1764d657e0f7a9b139bc7269c8d5f5a2534b.tar.bz2
linux-stable-694a1764d657e0f7a9b139bc7269c8d5f5a2534b.zip
[patch 3/4] vfs: fix ERR_PTR abuse in generic_readlink
generic_readlink calls ERR_PTR for negative and positive values (vfs_readlink returns length of "link"), but it should not (not an errno) and does not need to. Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de> Acked-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/namei.c b/fs/namei.c
index ee1544696e83..01e67dddcc3d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2856,16 +2856,17 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
{
struct nameidata nd;
void *cookie;
+ int res;
nd.depth = 0;
cookie = dentry->d_inode->i_op->follow_link(dentry, &nd);
- if (!IS_ERR(cookie)) {
- int res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd));
- if (dentry->d_inode->i_op->put_link)
- dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
- cookie = ERR_PTR(res);
- }
- return PTR_ERR(cookie);
+ if (IS_ERR(cookie))
+ return PTR_ERR(cookie);
+
+ res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd));
+ if (dentry->d_inode->i_op->put_link)
+ dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
+ return res;
}
int vfs_follow_link(struct nameidata *nd, const char *link)