diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/random32.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/random32.c b/lib/random32.c index 82da4f4c3489..1e5b2df44291 100644 --- a/lib/random32.c +++ b/lib/random32.c | |||
@@ -214,18 +214,22 @@ static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0); | |||
214 | static void __prandom_timer(unsigned long dontcare) | 214 | static void __prandom_timer(unsigned long dontcare) |
215 | { | 215 | { |
216 | u32 entropy; | 216 | u32 entropy; |
217 | unsigned long expires; | ||
217 | 218 | ||
218 | get_random_bytes(&entropy, sizeof(entropy)); | 219 | get_random_bytes(&entropy, sizeof(entropy)); |
219 | prandom_seed(entropy); | 220 | prandom_seed(entropy); |
221 | |||
220 | /* reseed every ~60 seconds, in [40 .. 80) interval with slack */ | 222 | /* reseed every ~60 seconds, in [40 .. 80) interval with slack */ |
221 | seed_timer.expires = jiffies + (40 * HZ + (prandom_u32() % (40 * HZ))); | 223 | expires = 40 + (prandom_u32() % 40); |
224 | seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC); | ||
225 | |||
222 | add_timer(&seed_timer); | 226 | add_timer(&seed_timer); |
223 | } | 227 | } |
224 | 228 | ||
225 | static void prandom_start_seed_timer(void) | 229 | static void __init __prandom_start_seed_timer(void) |
226 | { | 230 | { |
227 | set_timer_slack(&seed_timer, HZ); | 231 | set_timer_slack(&seed_timer, HZ); |
228 | seed_timer.expires = jiffies + 40 * HZ; | 232 | seed_timer.expires = jiffies + msecs_to_jiffies(40 * MSEC_PER_SEC); |
229 | add_timer(&seed_timer); | 233 | add_timer(&seed_timer); |
230 | } | 234 | } |
231 | 235 | ||
@@ -270,7 +274,7 @@ void prandom_reseed_late(void) | |||
270 | static int __init prandom_reseed(void) | 274 | static int __init prandom_reseed(void) |
271 | { | 275 | { |
272 | __prandom_reseed(false); | 276 | __prandom_reseed(false); |
273 | prandom_start_seed_timer(); | 277 | __prandom_start_seed_timer(); |
274 | return 0; | 278 | return 0; |
275 | } | 279 | } |
276 | late_initcall(prandom_reseed); | 280 | late_initcall(prandom_reseed); |