Commit 4661786b authored by Al Viro's avatar Al Viro Committed by Sasha Levin

hexagon: fix strncpy_from_user() error return

[ Upstream commit f35c1e06 ]

It's -EFAULT, not -1 (and contrary to the comment in there,
__strnlen_user() can return 0 - on faults).

Cc: stable@vger.kernel.org
Acked-by: default avatarRichard Kuo <rkuo@codeaurora.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent bd2f050b
...@@ -102,7 +102,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, ...@@ -102,7 +102,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src,
{ {
long res = __strnlen_user(src, n); long res = __strnlen_user(src, n);
/* return from strnlen can't be zero -- that would be rubbish. */ if (unlikely(!res))
return -EFAULT;
if (res > n) { if (res > n) {
copy_from_user(dst, src, n); copy_from_user(dst, src, n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment