diff mbox series

[COMMITTED] linux: Fix clock_getres fallback

Message ID 20210518200318.1406817-1-adhemerval.zanella@linaro.org
State New
Headers show
Series [COMMITTED] linux: Fix clock_getres fallback | expand

Commit Message

Adhemerval Zanella May 18, 2021, 8:03 p.m. UTC
The tst-timespec_getres (e5ac7bd679de5) triggers an issue on 32-bit
architecture on Linux older than 5.1, where the fallback syscall
is used.

Checked on powerpc-linux-gnu.
---
 sysdeps/unix/sysv/linux/clock_getres.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joseph Myers May 18, 2021, 8:39 p.m. UTC | #1
On Tue, 18 May 2021, Adhemerval Zanella via Libc-alpha wrote:

> The tst-timespec_getres (e5ac7bd679de5) triggers an issue on 32-bit
> architecture on Linux older than 5.1, where the fallback syscall
> is used.

I think this shows the need for a test of direct use of clock_getres with 
a NULL pointer, rather than relying on it being indirectly tested via 
timespec_getres.
Adhemerval Zanella May 18, 2021, 8:41 p.m. UTC | #2
On 18/05/2021 17:39, Joseph Myers wrote:
> On Tue, 18 May 2021, Adhemerval Zanella via Libc-alpha wrote:
> 
>> The tst-timespec_getres (e5ac7bd679de5) triggers an issue on 32-bit
>> architecture on Linux older than 5.1, where the fallback syscall
>> is used.
> 
> I think this shows the need for a test of direct use of clock_getres with 
> a NULL pointer, rather than relying on it being indirectly tested via 
> timespec_getres.
> 

Indeed, I will add one based on the timespec_getres.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c
index d560cd7c48..a9edec93e6 100644
--- a/sysdeps/unix/sysv/linux/clock_getres.c
+++ b/sysdeps/unix/sysv/linux/clock_getres.c
@@ -56,7 +56,7 @@  __clock_getres64 (clockid_t clock_id, struct __timespec64 *res)
 # else
   r = INLINE_SYSCALL_CALL (clock_getres, clock_id, &ts32);
 # endif
-  if (r == 0)
+  if (r == 0 && res != NULL)
     *res = valid_timespec_to_timespec64 (ts32);
 #endif