Skip to content

Commit a9445e4

Browse files
mrpgKAGA-KOKO
authored andcommitted
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
1 parent 103bb56 commit a9445e4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/time/posix-cpu-timers.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
11891189
u64 now;
11901190

11911191
WARN_ON_ONCE(clock_idx == CPUCLOCK_SCHED);
1192-
cpu_timer_sample_group(clock_idx, tsk, &now);
11931192

1194-
if (oldval) {
1193+
if (oldval && cpu_timer_sample_group(clock_idx, tsk, &now) != -EINVAL) {
11951194
/*
11961195
* We are setting itimer. The *oldval is absolute and we update
11971196
* it to be relative, *newval argument is relative and we update

0 commit comments

Comments
 (0)