On some machines arch_get_random_long() gives 64 bits. XORing it into a 32-bit state word uses only half of it. This change makes it use it all instead. Signed-off-by: Sandy Harris <sandyinchina@xxxxxxxxx> --- drivers/char/random.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 57fe011fb5e4..fe7f3366b934 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -988,7 +988,8 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r) static void _extract_crng(struct crng_state *crng, __u8 out[CHACHA_BLOCK_SIZE]) { - unsigned long v, flags; + unsigned long v, flags, *last; + last = (unsigned long *) &crng->state[14] ; if (crng_ready() && (time_after(crng_global_init_time, crng->init_time) || @@ -996,7 +997,7 @@ static void _extract_crng(struct crng_state *crng, crng_reseed(crng, crng == &primary_crng ? &input_pool : NULL); spin_lock_irqsave(&crng->lock, flags); if (arch_get_random_long(&v)) - crng->state[14] ^= v; + *last ^= v; chacha20_block(&crng->state[0], out); if (crng->state[12] == 0) crng->state[13]++; --