posix-timers: Accept NULL clock_getres() output in stubs
Subsystems (2)
PATCH 1/1 posix-timers: Accept NULL clock_getres() output in stubs
With CONFIG_POSIX_TIMERS disabled, clock_getres() returns -EFAULT for a supported clock when the result pointer is NULL. POSIX permits a NULL result pointer to suppress returning the clock resolution.
Only copy the result when a destination is provided, in both the native and time32 stubs. This matches the full POSIX timer implementation and preserves clock ID validation.
--- kernel/time/posix-stubs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/time/posix-stubs.c +2 -2
@@ -83,7 +83,7 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_timecase CLOCK_REALTIME :case CLOCK_MONOTONIC :case CLOCK_BOOTTIME : -if (put_timespec64 (&rtn_tp, tp)) +if (tp &&put_timespec64 (&rtn_tp, tp))return -EFAULT ;return 0 ;default :
@@ -166,7 +166,7 @@ SYSCALL_DEFINE2(clock_getres_time32, clockid_t, which_clock,case CLOCK_REALTIME :case CLOCK_MONOTONIC :case CLOCK_BOOTTIME : -if (put_old_timespec32 (&rtn_tp, tp)) +if (tp &&put_old_timespec32 (&rtn_tp, tp))return -EFAULT ;return 0 ;default :
base-commit: 348f54c435bf3177baa78201952810b255d44b30
The following commit has been merged into the timers/urgent branch of tip:
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: 5b819071e4346256c4edbae5cc2095dff25694fc Gitweb: https://git.kernel.org/tip/5b819071e4346256c4edbae5cc2095dff25694fc Author: Hungyu Lin <[email protected]> AuthorDate: Tue, 20 Oct 2026 16:11:21 Committer: Thomas Gleixner <[email protected]> CommitterDate: Sun, 25 Oct 2026 22:43:19 +01:00
posix-timers: Accept NULL clock_getres() output in stubs
With CONFIG_POSIX_TIMERS disabled, clock_getres() returns -EFAULT for a supported clock when the result pointer is NULL. POSIX permits a NULL result pointer to suppress returning the clock resolution.
Only copy the result when a destination is provided, in both the native and time32 stubs. This matches the full POSIX timer implementation and preserves clock ID validation.
--- kernel/time/posix-stubs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/time/posix-stubs.c +2 -2
@@ -83,7 +83,7 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_timecase CLOCK_REALTIME :case CLOCK_MONOTONIC :case CLOCK_BOOTTIME : -if (put_timespec64 (&rtn_tp, tp)) +if (tp &&put_timespec64 (&rtn_tp, tp))return -EFAULT ;return 0 ;default :
@@ -166,7 +166,7 @@ SYSCALL_DEFINE2(clock_getres_time32, clockid_t, which_clock,case CLOCK_REALTIME :case CLOCK_MONOTONIC :case CLOCK_BOOTTIME : -if (put_old_timespec32 (&rtn_tp, tp)) +if (tp &&put_old_timespec32 (&rtn_tp, tp))return -EFAULT ;return 0 ;default :