[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>
This commit is contained in:
parent
20d4fdc1a7
commit
694a1764d6
1 changed files with 8 additions and 7 deletions
15
fs/namei.c
15
fs/namei.c
|
@ -2856,16 +2856,17 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
|
||||||
{
|
{
|
||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
void *cookie;
|
void *cookie;
|
||||||
|
int res;
|
||||||
|
|
||||||
nd.depth = 0;
|
nd.depth = 0;
|
||||||
cookie = dentry->d_inode->i_op->follow_link(dentry, &nd);
|
cookie = dentry->d_inode->i_op->follow_link(dentry, &nd);
|
||||||
if (!IS_ERR(cookie)) {
|
if (IS_ERR(cookie))
|
||||||
int res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd));
|
return PTR_ERR(cookie);
|
||||||
if (dentry->d_inode->i_op->put_link)
|
|
||||||
dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
|
res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd));
|
||||||
cookie = ERR_PTR(res);
|
if (dentry->d_inode->i_op->put_link)
|
||||||
}
|
dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
|
||||||
return PTR_ERR(cookie);
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vfs_follow_link(struct nameidata *nd, const char *link)
|
int vfs_follow_link(struct nameidata *nd, const char *link)
|
||||||
|
|
Loading…
Reference in a new issue