Skip to content

Commit 1638b8f

Browse files
committed
lib/vdso: Make clock_getres() POSIX compliant again
A recent commit removed the NULL pointer check from the clock_getres() implementation causing a test case to fault. POSIX requires an explicit NULL pointer check for clock_getres() aside of the validity check of the clock_id argument for obscure reasons. Add it back for both 32bit and 64bit. Note, this is only a partial revert of the offending commit which does not bring back the broken fallback invocation in the the 32bit compat implementations of clock_getres() and clock_gettime(). Fixes: a9446a9 ("lib/vdso/32: Remove inconsistent NULL pointer checks") Reported-by: Andreas Schwab <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Christophe Leroy <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 7d194c2 commit 1638b8f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/vdso/gettimeofday.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
214214
return -1;
215215
}
216216

217-
res->tv_sec = 0;
218-
res->tv_nsec = ns;
219-
217+
if (likely(res)) {
218+
res->tv_sec = 0;
219+
res->tv_nsec = ns;
220+
}
220221
return 0;
221222
}
222223

@@ -245,7 +246,7 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res)
245246
ret = clock_getres_fallback(clock, &ts);
246247
#endif
247248

248-
if (likely(!ret)) {
249+
if (likely(!ret && res)) {
249250
res->tv_sec = ts.tv_sec;
250251
res->tv_nsec = ts.tv_nsec;
251252
}

0 commit comments

Comments
 (0)