summaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorMax R. P. Grossmann <m@max.pm>2018-01-08 20:01:57 +0100
committerThomas Gleixner <tglx@linutronix.de>2018-01-14 20:50:59 +0100
commita9445e47d897054876b8f43e46dc5a3eca2b844d (patch)
treed41dc9179e6aea71584e6276b7dcf261d4d1ed49 /kernel/time
parentclocksource/drivers/stm32: Start the timer's counter sooner (diff)
downloadlinux-a9445e47d897054876b8f43e46dc5a3eca2b844d.tar.xz
linux-a9445e47d897054876b8f43e46dc5a3eca2b844d.zip
posix-cpu-timers: Make set_process_cpu_timer() more robust
Because the return value of cpu_timer_sample_group() is not checked, compilers and static checkers can legitimately warn about a potential use of the uninitialized variable 'now'. This is not a runtime issue as all call sites hand in valid clock ids. Also cpu_timer_sample_group() is invoked unconditionally even when the result is not used because *oldval is NULL. Make the invocation conditional and check the return value. [ tglx: Massage changelog ] Signed-off-by: Max R. P. Grossmann <m@max.pm> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: john.stultz@linaro.org Link: https://lkml.kernel.org/r/20180108190157.10048-1-m@max.pm
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/posix-cpu-timers.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index cef79ca5bbd5..ec9f5da6f163 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1189,9 +1189,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
u64 now;
WARN_ON_ONCE(clock_idx == CPUCLOCK_SCHED);
- cpu_timer_sample_group(clock_idx, tsk, &now);
- if (oldval) {
+ if (oldval && cpu_timer_sample_group(clock_idx, tsk, &now) != -EINVAL) {
/*
* We are setting itimer. The *oldval is absolute and we update
* it to be relative, *newval argument is relative and we update