Skip to content

Commit

Permalink
fix typo/thinko in get_random_bytes()
Browse files Browse the repository at this point in the history
If there is an architecture-specific random number generator we use it
to acquire randomness one "long" at a time.  We should put these random
words into consecutive words in the result buffer - not just overwrite
the first word again and again.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Luck, Tony authored and Linus Torvalds committed Nov 17, 2011
1 parent 869f8df commit bd29e56
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ void get_random_bytes(void *buf, int nbytes)
if (!arch_get_random_long(&v))
break;

memcpy(buf, &v, chunk);
memcpy(p, &v, chunk);
p += chunk;
nbytes -= chunk;
}
Expand Down

0 comments on commit bd29e56

Please sign in to comment.