mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: John Stultz <john.stultz@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Prarit Bhargava <prarit@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH] time: Fix casting issue in timekeeping_forward_now
Date: Sun, 19 Aug 2012 22:09:01 +0200	[thread overview]
Message-ID: <m2mx1qlk4i.fsf@igel.home> (raw)
In-Reply-To: <1343074957-16541-1-git-send-email-john.stultz@linaro.org> (John Stultz's message of "Mon, 23 Jul 2012 16:22:37 -0400")

arch_gettimeoffset returns a u32 value which when shifted by tk->shift can
overflow.  Cast it to u64 first.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
Found this by inspection, I don't know if any existing users of
ARCH_USES_GETTIMEOFFSET are affected.  In other words, this is untested,
but looks pretty obvious.

Can tk->shift be bigger than 30?  If so then the shifts in
update_wall_time need to be adjusted as well.

Andreas.

---
 kernel/time/timekeeping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index e16af19..8776d66 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -276,7 +276,7 @@ static void timekeeping_forward_now(struct timekeeper *tk)
 	tk->xtime_nsec += cycle_delta * tk->mult;
 
 	/* If arch requires, add in gettimeoffset() */
-	tk->xtime_nsec += arch_gettimeoffset() << tk->shift;
+	tk->xtime_nsec += (u64)arch_gettimeoffset() << tk->shift;
 
 	tk_normalize_xtime(tk);
 
-- 
1.7.11.5

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

      parent reply	other threads:[~2012-08-19 20:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-23 20:22 [PATCH] time: Fix casting issue in tk_set_xtime and tk_xtime_add John Stultz
2012-07-24 12:08 ` Prarit Bhargava
2012-07-24 14:55 ` [tip:timers/urgent] " tip-bot for John Stultz
2012-08-19 20:09 ` Andreas Schwab [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2mx1qlk4i.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=john.stultz@linaro.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=prarit@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome