Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d2f096b authored by Tony Luck's avatar Tony Luck Committed by H. Peter Anvin
Browse files

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: default avatarTony Luck <tony.luck@intel.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/4ec4061010261a4cb0@agluck-desktop.sc.intel.com


Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 78345d2e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}