From 321c5e865665eb7c843db5cdb111b9b5ff0d9e07 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Thu, 23 Mar 2023 08:53:27 +0100 Subject: [PATCH] drivers: entropy: stm32: Move irq_lock at init Perform clock check inside irq_lock in order to exit cleanly if failing. Signed-off-by: Erwan Gouriou --- drivers/entropy/entropy_stm32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/entropy/entropy_stm32.c b/drivers/entropy/entropy_stm32.c index 3dd8f82e8a5bb6..0abedb1940c150 100644 --- a/drivers/entropy/entropy_stm32.c +++ b/drivers/entropy/entropy_stm32.c @@ -235,6 +235,8 @@ static int random_byte_get(void) unsigned int key; RNG_TypeDef *rng = entropy_stm32_rng_data.rng; + key = irq_lock(); + if (IS_ENABLED(CONFIG_ENTROPY_STM32_CLK_CHECK) && !k_is_pre_kernel()) { /* CECS bit signals that a clock configuration issue is detected, * which may lead to generation of non truly random data. @@ -244,8 +246,6 @@ static int random_byte_get(void) "\tSee ref man and update target clock configuration."); } - key = irq_lock(); - if (LL_RNG_IsActiveFlag_SEIS(rng) && (recover_seed_error(rng) < 0)) { retval = -EIO; goto out;