From: Al Viro Date: Fri, 19 Aug 2016 01:16:49 +0000 (-0400) Subject: hexagon: fix strncpy_from_user() error return X-Git-Tag: v4.4.22~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0be8d73a033a3fee288c8f51990213449e94b204;p=profile%2Fcommon%2Fplatform%2Fkernel%2Flinux-artik7.git hexagon: fix strncpy_from_user() error return commit f35c1e0671728d1c9abc405d05ef548b5fcb2fc4 upstream. It's -EFAULT, not -1 (and contrary to the comment in there, __strnlen_user() can return 0 - on faults). Acked-by: Richard Kuo Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h index f000a38..f61cfb2 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h @@ -103,7 +103,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, { 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) { copy_from_user(dst, src, n);