random: move initialization out of reseeding hot path
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 9 May 2022 11:53:24 +0000 (13:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 May 2022 07:27:16 +0000 (09:27 +0200)
commite6b205dcc981e401651cfb657d5338d74f2d460c
treee86d489ada483a69fcfe7dbeac2f4bd0303885e3
parent8fe9ac5ed215ade6f1cd23415b3474fbb6e3f7fa
random: move initialization out of reseeding hot path

commit 68c9c8b192c6dae9be6278e98ee44029d5da2d31 upstream.

Initialization happens once -- by way of credit_init_bits() -- and then
it never happens again. Therefore, it doesn't need to be in
crng_reseed(), which is a hot path that is called multiple times. It
also doesn't make sense to have there, as initialization activity is
better associated with initialization routines.

After the prior commit, crng_reseed() now won't be called by multiple
concurrent callers, which means that we can safely move the
"finialize_init" logic into crng_init_bits() unconditionally.

Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c