diff options
author | Sean Paul <seanpaul@chromium.org> | 2018-03-30 18:35:45 +0200 |
---|---|---|
committer | Sean Paul <seanpaul@chromium.org> | 2018-03-30 18:35:45 +0200 |
commit | 83fd26c3f32afe38bb2ab8cc00e313ec5c2edbce (patch) | |
tree | b2d2719c998bc2bcba99f2ecf2d164ee9b7ad75a /kernel/time/posix-timers.c | |
parent | drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug (diff) | |
parent | Merge branch 'drm-misc-next-fixes' of git://anongit.freedesktop.org/drm/drm-m... (diff) | |
download | linux-83fd26c3f32afe38bb2ab8cc00e313ec5c2edbce.tar.xz linux-83fd26c3f32afe38bb2ab8cc00e313ec5c2edbce.zip |
Merge airlied/drm-next into drm-misc-next
Backmerging to pick up a fix from drm-misc-next-fixes.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Diffstat (limited to 'kernel/time/posix-timers.c')
-rw-r--r-- | kernel/time/posix-timers.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 75043046914e..10b7186d0638 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -50,6 +50,7 @@ #include <linux/export.h> #include <linux/hashtable.h> #include <linux/compat.h> +#include <linux/nospec.h> #include "timekeeping.h" #include "posix-timers.h" @@ -1346,11 +1347,15 @@ static const struct k_clock * const posix_clocks[] = { static const struct k_clock *clockid_to_kclock(const clockid_t id) { - if (id < 0) + clockid_t idx = id; + + if (id < 0) { return (id & CLOCKFD_MASK) == CLOCKFD ? &clock_posix_dynamic : &clock_posix_cpu; + } - if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id]) + if (id >= ARRAY_SIZE(posix_clocks)) return NULL; - return posix_clocks[id]; + + return posix_clocks[array_index_nospec(idx, ARRAY_SIZE(posix_clocks))]; } |