Skip to content

Commit 0d2f096

Browse files
aeglH. Peter Anvin
authored andcommitted
random: Fix handing of arch_get_random_long in get_random_bytes()
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>
1 parent 78345d2 commit 0d2f096

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/char/random.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ void get_random_bytes(void *buf, int nbytes)
941941
if (!arch_get_random_long(&v))
942942
break;
943943

944-
memcpy(buf, &v, chunk);
944+
memcpy(p, &v, chunk);
945945
p += chunk;
946946
nbytes -= chunk;
947947
}

0 commit comments

Comments
 (0)