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

Configure Feed

Select the types of activity you want to include in your feed.

vdso/gettimeofday: Introduce vdso_clockid_valid()

Move the clock ID validation check into a common helper.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250701-vdso-auxclock-v1-7-df7d9f87b9b8@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
1a1cd5fe fb61bdb2

+8 -4
+8 -4
lib/vdso/gettimeofday.c
··· 71 71 } 72 72 #endif 73 73 74 + static __always_inline bool vdso_clockid_valid(clockid_t clock) 75 + { 76 + /* Check for negative values or invalid clocks */ 77 + return likely((u32) clock < MAX_CLOCKS); 78 + } 79 + 74 80 #ifdef CONFIG_TIME_NS 75 81 76 82 #ifdef CONFIG_GENERIC_VDSO_DATA_STORE ··· 274 268 const struct vdso_clock *vc = vd->clock_data; 275 269 u32 msk; 276 270 277 - /* Check for negative values or invalid clocks */ 278 - if (unlikely((u32) clock >= MAX_CLOCKS)) 271 + if (!vdso_clockid_valid(clock)) 279 272 return false; 280 273 281 274 /* ··· 410 405 u32 msk; 411 406 u64 ns; 412 407 413 - /* Check for negative values or invalid clocks */ 414 - if (unlikely((u32) clock >= MAX_CLOCKS)) 408 + if (!vdso_clockid_valid(clock)) 415 409 return false; 416 410 417 411 if (IS_ENABLED(CONFIG_TIME_NS) &&