aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-06-09 19:40:37 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-06-23 11:52:30 -0400
commit694a1764d657e0f7a9b139bc7269c8d5f5a2534b (patch)
tree754e073cce539c3b6f93e61c3f729bc5959f12f4 /fs
parent20d4fdc1a788e4ca0aaf2422772ba668e7e10839 (diff)
[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 ee1544696e8..01e67dddcc3 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2856,16 +2856,17 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
2856{ 2856{
2857 struct nameidata nd; 2857 struct nameidata nd;
2858 void *cookie; 2858 void *cookie;
2859 int res;
2859 2860
2860 nd.depth = 0; 2861 nd.depth = 0;
2861 cookie = dentry->d_inode->i_op->follow_link(dentry, &nd); 2862 cookie = dentry->d_inode->i_op->follow_link(dentry, &nd);
2862 if (!IS_ERR(cookie)) { 2863 if (IS_ERR(cookie))
2863 int res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); 2864 return PTR_ERR(cookie);
2864 if (dentry->d_inode->i_op->put_link) 2865
2865 dentry->d_inode->i_op->put_link(dentry, &nd, cookie); 2866 res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd));
2866 cookie = ERR_PTR(res); 2867 if (dentry->d_inode->i_op->put_link)
2867 } 2868 dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
2868 return PTR_ERR(cookie); 2869 return res;
2869} 2870}
2870 2871
2871int vfs_follow_link(struct nameidata *nd, const char *link) 2872int vfs_follow_link(struct nameidata *nd, const char *link)