From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752049AbeANT5V (ORCPT + 1 other); Sun, 14 Jan 2018 14:57:21 -0500 Received: from terminus.zytor.com ([65.50.211.136]:54087 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbeANT5U (ORCPT ); Sun, 14 Jan 2018 14:57:20 -0500 Date: Sun, 14 Jan 2018 11:55:07 -0800 From: "tip-bot for Max R. P. Grossmann" Message-ID: Cc: mingo@kernel.org, m@max.pm, hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: m@max.pm, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de In-Reply-To: <20180108190157.10048-1-m@max.pm> References: <20180108190157.10048-1-m@max.pm> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] posix-cpu-timers: Make set_process_cpu_timer() more robust Git-Commit-ID: a9445e47d897054876b8f43e46dc5a3eca2b844d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Commit-ID: a9445e47d897054876b8f43e46dc5a3eca2b844d Gitweb: https://git.kernel.org/tip/a9445e47d897054876b8f43e46dc5a3eca2b844d Author: Max R. P. Grossmann AuthorDate: Mon, 8 Jan 2018 20:01:57 +0100 Committer: Thomas Gleixner CommitDate: Sun, 14 Jan 2018 20:50:59 +0100 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 Signed-off-by: Thomas Gleixner Cc: john.stultz@linaro.org Link: https://lkml.kernel.org/r/20180108190157.10048-1-m@max.pm --- kernel/time/posix-cpu-timers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index cef79ca..ec9f5da 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