From 611f60b5fbc14f0c2ca31476e8f7ebd8cb442402 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 17 Feb 2022 17:23:57 +0100 Subject: libblake_init: return before locking if already initialised (check-lock-check) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libblake_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libblake_init.c b/libblake_init.c index 84dd87e..0276cd2 100644 --- a/libblake_init.c +++ b/libblake_init.c @@ -15,6 +15,9 @@ libblake_init(void) static volatile int initialised = 0; static volatile atomic_flag spinlock = ATOMIC_FLAG_INIT; + if (initialised) + return; + while (atomic_flag_test_and_set(&spinlock)); if (!initialised) { -- cgit v1.2.3-70-g09d2