summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2021-01-05 14:52:45 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-01-07 16:57:32 +0100
commit662d82cf39ff60df33b6af6c8da71e900e65350a (patch)
tree2885c253dbc8da7535e4171a5bdc4134f469695e
parent04dfd7273398e7321b50c11311e303a9af2f30f9 (diff)
downloadlinux-stable-662d82cf39ff60df33b6af6c8da71e900e65350a.tar.gz
linux-stable-662d82cf39ff60df33b6af6c8da71e900e65350a.tar.bz2
linux-stable-662d82cf39ff60df33b6af6c8da71e900e65350a.zip
staging: vchiq: fix uninitialized variable copy
Smatch found a local variable that can get copied to another local variable without an initializion in the error case: drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:1056 vchiq_get_user_ptr() error: uninitialized symbol 'ptr'. This seems harmless, as the function should normally get inlined, with the output directly written or not. In any case, the uninitialized data is never used after get_user() fails. As Dan mentions, it could still trigger an UBSAN runtime error, and it is of course a bad idea to copy uninitialized variables, so just bail out early. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20210105135256.1810337-1-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 23f4389cf51d..59e45dc03a97 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -1052,14 +1052,21 @@ static inline int vchiq_get_user_ptr(void __user **buf, void __user *ubuf, int i
compat_uptr_t ptr32;
compat_uptr_t __user *uptr = ubuf;
ret = get_user(ptr32, uptr + index);
+ if (ret)
+ return ret;
+
*buf = compat_ptr(ptr32);
} else {
uintptr_t ptr, __user *uptr = ubuf;
ret = get_user(ptr, uptr + index);
+
+ if (ret)
+ return ret;
+
*buf = (void __user *)ptr;
}
- return ret;
+ return 0;
}
struct vchiq_completion_data32 {