]> git.baikalelectronics.ru Git - kernel.git/commit
random: avoid checking crng_ready() twice in random_init()
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 7 Jun 2022 07:44:07 +0000 (09:44 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 10 Jun 2022 09:09:36 +0000 (11:09 +0200)
commit9bbef53c7e61c593afd352549443e588bf3c0400
tree90ba493df6bc5a7da74b9c9507c9d0fa6d0d652b
parentc8b191523d512ad5727aee67c7f52d67f92fd664
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: 2248570c88b7 ("random: move initialization functions out of hot pages")
Cc: stable@vger.kernel.org
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c