Skip to content

Commit 9b29b6b

Browse files
committed
random: avoid checking crng_ready() twice in random_init()
The current flow expands to: if (crng_ready()) ... else if (...) if (!crng_ready()) ... The second crng_ready() call is redundant, but can't so easily be optimized out by the compiler. This commit simplifies that to: if (crng_ready() ... else if (...) ... Fixes: 560181c ("random: move initialization functions out of hot pages") Cc: [email protected] Cc: Dominik Brodowski <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 7799164 commit 9b29b6b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/char/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ int __init random_init(const char *command_line)
801801
if (crng_ready())
802802
crng_reseed();
803803
else if (trust_cpu)
804-
credit_init_bits(arch_bytes * 8);
804+
_credit_init_bits(arch_bytes * 8);
805805
used_arch_random = arch_bytes * 8 >= POOL_READY_BITS;
806806

807807
WARN_ON(register_pm_notifier(&pm_notifier));

0 commit comments

Comments
 (0)