Skip to content

Commit

Permalink
random: Fix handing of arch_get_random_long 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: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/4ec4061010261a4cb0@agluck-desktop.sc.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Luck, Tony authored and H. Peter Anvin committed Nov 17, 2011
1 parent 78345d2 commit 0d2f096
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 0d2f096

Please sign in to comment.