Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1637098 > unrolled thread

[PATCH] char: random: casting prevents missing calculations

Started byKarim Eshapa <karim.eshapa@gmail.com>
First post2017-05-08 00:20 +0200
Last post2017-05-08 00:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] char: random: casting prevents missing calculations Karim Eshapa <karim.eshapa@gmail.com> - 2017-05-08 00:20 +0200

#1637098 — [PATCH] char: random: casting prevents missing calculations

FromKarim Eshapa <karim.eshapa@gmail.com>
Date2017-05-08 00:20 +0200
Subject[PATCH] char: random: casting prevents missing calculations
Message-ID<tECdY-30b-7@gated-at.bofh.it>
Cast (long)jiffies and (long)state->last_time beacause
they tends to unsigned long. may cause a problem specially
when comparison happens (< 0).

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
---
 drivers/char/random.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0ab0249..f685e78 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1012,7 +1012,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
 
 	preempt_disable();
 
-	sample.jiffies = jiffies;
+	sample.jiffies = (long)jiffies;
 	sample.cycles = random_get_entropy();
 	sample.num = num;
 	r = &input_pool;
@@ -1025,7 +1025,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
 	 */
 
 	if (!state->dont_count_entropy) {
-		delta = sample.jiffies - state->last_time;
+		delta = sample.jiffies - (long)state->last_time;
 		state->last_time = sample.jiffies;
 
 		delta2 = delta - state->last_delta;
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web