mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix dccp_timestamp()'s use of do_div()
@ 2008-07-11 13:57 David Howells
  2008-07-12 13:14 ` Gerrit Renker
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2008-07-11 13:57 UTC (permalink / raw)
  To: gerrit, akpm; +Cc: dhowells, acme, netdev, linux-kernel

Fix dccp_timestamps()'s use of do_div() on an s64 by making delta a u64
instead and dividing that.

Possibly this should be guarded lest the interval calculation turn up negative,
but the possible negativity of the result of the division ignored anyway, and,
indeed, should not happen.

This was introduced by patch 4c70f383e0c0273c4092c4efdb414be0966978b7.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/dccp/timer.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 8703a79..27218c5 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -300,8 +300,10 @@ static ktime_t dccp_timestamp_seed;
  */
 u32 dccp_timestamp(void)
 {
-	s64 delta = ktime_us_delta(ktime_get_real(), dccp_timestamp_seed);
+	u64 delta = ktime_us_delta(ktime_get_real(), dccp_timestamp_seed);
 
+	/* This will produce huge values if the current time should happen to
+	 * be earlier than the initial timestamp, but that shouldn't happen */
 	do_div(delta, 10);
 	return delta;
 }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-12 13:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-11 13:57 [PATCH] Fix dccp_timestamp()'s use of do_div() David Howells
2008-07-12 13:14 ` Gerrit Renker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®