random: avoid checking crng_ready() twice in random_init()
Jason A. Donenfeld
maintainerPATCH 1/1 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 560181c27b58 ("random: move initialization functions out of hot pages")
Cc Dominik Brodowski <[email protected]>
Signed-off-by Jason A. Donenfeld <[email protected]>
--- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
@@ -801,7 +801,7 @@ int __init random_init(const char *command_line)if (crng_ready ())crng_reseed ();else if (trust_cpu) -credit_init_bits (arch_bytes *8 ); +_credit_init_bits (arch_bytes *8 ); used_arch_random = arch_bytes *8 >=POOL_READY_BITS ;WARN_ON (register_pm_notifier (&pm_notifier));
Signature · 1 line
2.35.1