Skip to content

Commit a9446a9

Browse files
committed
lib/vdso/32: Remove inconsistent NULL pointer checks
The 32bit variants of vdso_clock_gettime()/getres() have a NULL pointer check for the timespec pointer. That's inconsistent vs. 64bit. But the vdso implementation will never be consistent versus the syscall because the only case which it can handle is NULL. Any other invalid pointer will cause a segfault. So special casing NULL is not really useful. Remove it along with the superflouos syscall fallback invocation as that will return -EFAULT anyway. That also gets rid of the dubious typecast which only works because the pointer is NULL. Fixes: 00b2647 ("lib/vdso: Provide generic VDSO implementation") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Reviewed-by: Andy Lutomirski <luto@kernel.org> Link: https://lkml.kernel.org/r/20190728131648.587523358@linutronix.de
1 parent 629f820 commit a9446a9

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

‎lib/vdso/gettimeofday.c‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res)
115115
struct __kernel_timespec ts;
116116
int ret;
117117

118-
if (res == NULL)
119-
goto fallback;
120-
121118
ret = __cvdso_clock_gettime(clock, &ts);
122119

123120
if (ret == 0) {
@@ -126,9 +123,6 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res)
126123
}
127124

128125
return ret;
129-
130-
fallback:
131-
return clock_gettime_fallback(clock, (struct __kernel_timespec *)res);
132126
}
133127

134128
static __maybe_unused int
@@ -204,10 +198,8 @@ int __cvdso_clock_getres(clockid_t clock, struct __kernel_timespec *res)
204198
goto fallback;
205199
}
206200

207-
if (res) {
208-
res->tv_sec = 0;
209-
res->tv_nsec = ns;
210-
}
201+
res->tv_sec = 0;
202+
res->tv_nsec = ns;
211203

212204
return 0;
213205

@@ -221,9 +213,6 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res)
221213
struct __kernel_timespec ts;
222214
int ret;
223215

224-
if (res == NULL)
225-
goto fallback;
226-
227216
ret = __cvdso_clock_getres(clock, &ts);
228217

229218
if (ret == 0) {
@@ -232,8 +221,5 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res)
232221
}
233222

234223
return ret;
235-
236-
fallback:
237-
return clock_getres_fallback(clock, (struct __kernel_timespec *)res);
238224
}
239225
#endif /* VDSO_HAS_CLOCK_GETRES */

0 commit comments

Comments
 (0)