Skip to content

Commit

Permalink
drivers: entropy: stm32: Move irq_lock at init
Browse files Browse the repository at this point in the history
Perform clock check inside irq_lock in order to exit cleanly
if failing.

Signed-off-by: Erwan Gouriou <[email protected]>
  • Loading branch information
erwango authored and carlescufi committed Nov 15, 2023
1 parent 2deea4e commit 321c5e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/entropy/entropy_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down

0 comments on commit 321c5e8

Please sign in to comment.