]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
random: drop check for static_key_initialized
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Tue, 11 Nov 2025 00:13:06 +0000 (01:13 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 11 Nov 2025 00:25:31 +0000 (01:25 +0100)
Commit e871abcda3b6 ("random: handle creditable entropy from atomic
process context") added the use of workqueues, which meant testing
whether the workqueue is valid, but it did not remove the existing check
of whether static keys have been initialized. This static key check is
unnecessary because workqueues are initialized long after it. And
semantically it doesn't make much sense either, because it's not really
directly calling a static key function in the condition.

Remove the now unnecessary check.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
[Jason: rewrite commit message with different explanation, rebase on
        random.git, and update code comment.]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c

index 6873ec481d73e6ab72296ad4d3306a6959541e89..2c7195c942c36bf7680595705a42fc46928e1e30 100644 (file)
@@ -741,7 +741,7 @@ static void __cold _credit_init_bits(size_t bits)
 
        if (orig < POOL_READY_BITS && new >= POOL_READY_BITS) {
                crng_reseed(NULL); /* Sets crng_init to CRNG_READY under base_crng.lock. */
-               if (static_key_initialized && system_dfl_wq)
+               if (system_dfl_wq)
                        queue_work(system_dfl_wq, &set_ready);
                atomic_notifier_call_chain(&random_ready_notifier, 0, NULL);
 #ifdef CONFIG_VDSO_GETRANDOM
@@ -915,9 +915,8 @@ void __init random_init(void)
        add_latent_entropy();
 
        /*
-        * If we were initialized by the cpu or bootloader before jump labels
-        * or workqueues are initialized, then we should enable the static
-        * branch here, where it's guaranteed that these have been initialized.
+        * If we were initialized by the cpu or bootloader before workqueues
+        * are initialized, then we should enable the static branch here.
         */
        if (!static_branch_likely(&crng_is_ready) && crng_init >= CRNG_READY)
                crng_set_ready(NULL);