mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
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
This commit is contained in:
committed by
Thomas Gleixner
parent
fb61bdb27f
commit
1a1cd5fe88
@@ -71,6 +71,12 @@ static inline bool vdso_cycles_ok(u64 cycles)
|
||||
}
|
||||
#endif
|
||||
|
||||
static __always_inline bool vdso_clockid_valid(clockid_t clock)
|
||||
{
|
||||
/* Check for negative values or invalid clocks */
|
||||
return likely((u32) clock < MAX_CLOCKS);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TIME_NS
|
||||
|
||||
#ifdef CONFIG_GENERIC_VDSO_DATA_STORE
|
||||
@@ -268,8 +274,7 @@ __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
|
||||
const struct vdso_clock *vc = vd->clock_data;
|
||||
u32 msk;
|
||||
|
||||
/* Check for negative values or invalid clocks */
|
||||
if (unlikely((u32) clock >= MAX_CLOCKS))
|
||||
if (!vdso_clockid_valid(clock))
|
||||
return false;
|
||||
|
||||
/*
|
||||
@@ -405,8 +410,7 @@ bool __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t cloc
|
||||
u32 msk;
|
||||
u64 ns;
|
||||
|
||||
/* Check for negative values or invalid clocks */
|
||||
if (unlikely((u32) clock >= MAX_CLOCKS))
|
||||
if (!vdso_clockid_valid(clock))
|
||||
return false;
|
||||
|
||||
if (IS_ENABLED(CONFIG_TIME_NS) &&
|
||||
|
||||
Reference in New Issue
Block a user