Commit ebf76063 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Jason A. Donenfeld

random: access primary_pool directly rather than through pointer

Both crng_initialize_primary() and crng_init_try_arch_early() are
only called for the primary_pool. Accessing it directly instead of
through a function parameter simplifies the code.
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
parent 042e293e
...@@ -762,7 +762,7 @@ static bool crng_init_try_arch(struct crng_state *crng) ...@@ -762,7 +762,7 @@ static bool crng_init_try_arch(struct crng_state *crng)
return arch_init; return arch_init;
} }
static bool __init crng_init_try_arch_early(struct crng_state *crng) static bool __init crng_init_try_arch_early(void)
{ {
int i; int i;
bool arch_init = true; bool arch_init = true;
...@@ -774,7 +774,7 @@ static bool __init crng_init_try_arch_early(struct crng_state *crng) ...@@ -774,7 +774,7 @@ static bool __init crng_init_try_arch_early(struct crng_state *crng)
rv = random_get_entropy(); rv = random_get_entropy();
arch_init = false; arch_init = false;
} }
crng->state[i] ^= rv; primary_crng.state[i] ^= rv;
} }
return arch_init; return arch_init;
...@@ -788,16 +788,16 @@ static void crng_initialize_secondary(struct crng_state *crng) ...@@ -788,16 +788,16 @@ static void crng_initialize_secondary(struct crng_state *crng)
crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
} }
static void __init crng_initialize_primary(struct crng_state *crng) static void __init crng_initialize_primary(void)
{ {
_extract_entropy(&crng->state[4], sizeof(u32) * 12); _extract_entropy(&primary_crng.state[4], sizeof(u32) * 12);
if (crng_init_try_arch_early(crng) && trust_cpu && crng_init < 2) { if (crng_init_try_arch_early() && trust_cpu && crng_init < 2) {
invalidate_batched_entropy(); invalidate_batched_entropy();
numa_crng_init(); numa_crng_init();
crng_init = 2; crng_init = 2;
pr_notice("crng init done (trusting CPU's manufacturer)\n"); pr_notice("crng init done (trusting CPU's manufacturer)\n");
} }
crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; primary_crng.init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
} }
static void crng_finalize_init(struct crng_state *crng) static void crng_finalize_init(struct crng_state *crng)
...@@ -1698,7 +1698,7 @@ int __init rand_initialize(void) ...@@ -1698,7 +1698,7 @@ int __init rand_initialize(void)
init_std_data(); init_std_data();
if (crng_need_final_init) if (crng_need_final_init)
crng_finalize_init(&primary_crng); crng_finalize_init(&primary_crng);
crng_initialize_primary(&primary_crng); crng_initialize_primary();
crng_global_init_time = jiffies; crng_global_init_time = jiffies;
if (ratelimit_disable) { if (ratelimit_disable) {
urandom_warning.interval = 0; urandom_warning.interval = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment