summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Holland <samuel.holland@sifive.com>2024-03-11 19:19:13 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-04-10 16:36:04 +0200
commit7a82963245eb5779bac7cc09100f799d4ebea30b (patch)
tree679219b4cc497a6dc7a359275aff85e5545c19bb
parent3dcb2223b973887f6360780f17ef99be38c3bbd3 (diff)
downloadlinux-stable-7a82963245eb5779bac7cc09100f799d4ebea30b.tar.gz
linux-stable-7a82963245eb5779bac7cc09100f799d4ebea30b.tar.bz2
linux-stable-7a82963245eb5779bac7cc09100f799d4ebea30b.zip
riscv: Fix spurious errors from __get/put_kernel_nofault
commit d080a08b06b6266cc3e0e86c5acfd80db937cb6b upstream. These macros did not initialize __kr_err, so they could fail even if the access did not fault. Cc: stable@vger.kernel.org Fixes: d464118cdc41 ("riscv: implement __get_kernel_nofault and __put_user_nofault") Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Link: https://lore.kernel.org/r/20240312022030.320789-1-samuel.holland@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/riscv/include/asm/uaccess.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
index ec0cab9fbddd..72ec1d9bd3f3 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -319,7 +319,7 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n)
#define __get_kernel_nofault(dst, src, type, err_label) \
do { \
- long __kr_err; \
+ long __kr_err = 0; \
\
__get_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \
if (unlikely(__kr_err)) \
@@ -328,7 +328,7 @@ do { \
#define __put_kernel_nofault(dst, src, type, err_label) \
do { \
- long __kr_err; \
+ long __kr_err = 0; \
\
__put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \
if (unlikely(__kr_err)) \