Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined

In the unlikely case that CLOCK_REALTIME is not defined, variable ret is
not initialized and further accumulation of return values to ret can leave
ret in an undefined state. Fix this by initialized ret to zero and changing
the assignment of ret to an accumulation for the CLOCK_REALTIME case.

Fixes: 03f55c7952c9 ("kselftest: Extend vDSO selftest to clock_getres")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Colin Ian King and committed by
Shuah Khan
375b9ff5 17cb2f17

+2 -2
+2 -2
tools/testing/selftests/vDSO/vdso_test_clock_getres.c
··· 84 84 85 85 int main(int argc, char **argv) 86 86 { 87 - int ret; 87 + int ret = 0; 88 88 89 89 #if _POSIX_TIMERS > 0 90 90 91 91 #ifdef CLOCK_REALTIME 92 - ret = vdso_test_clock(CLOCK_REALTIME); 92 + ret += vdso_test_clock(CLOCK_REALTIME); 93 93 #endif 94 94 95 95 #ifdef CLOCK_BOOTTIME