Commit 694a1764d657e0f7a9b139bc7269c8d5f5a2534b
Committed by
Al Viro
1 parent
20d4fdc1a7
Exists in
master
and in
4 other branches
[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>
Showing 1 changed file with 8 additions and 7 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -2856,16 +2856,17 @@ |
2856 | 2856 | { |
2857 | 2857 | struct nameidata nd; |
2858 | 2858 | void *cookie; |
2859 | + int res; | |
2859 | 2860 | |
2860 | 2861 | nd.depth = 0; |
2861 | 2862 | cookie = dentry->d_inode->i_op->follow_link(dentry, &nd); |
2862 | - if (!IS_ERR(cookie)) { | |
2863 | - int res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); | |
2864 | - if (dentry->d_inode->i_op->put_link) | |
2865 | - dentry->d_inode->i_op->put_link(dentry, &nd, cookie); | |
2866 | - cookie = ERR_PTR(res); | |
2867 | - } | |
2868 | - return PTR_ERR(cookie); | |
2863 | + if (IS_ERR(cookie)) | |
2864 | + return PTR_ERR(cookie); | |
2865 | + | |
2866 | + res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); | |
2867 | + if (dentry->d_inode->i_op->put_link) | |
2868 | + dentry->d_inode->i_op->put_link(dentry, &nd, cookie); | |
2869 | + return res; | |
2869 | 2870 | } |
2870 | 2871 | |
2871 | 2872 | int vfs_follow_link(struct nameidata *nd, const char *link) |