From 151edb44eea9bf25ec466133e9dbef87bd6b1372 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 Mar 2015 18:02:01 +0100 Subject: Add missing mutex-locking in procesc.c ; discovered design fault somewhere. --- src/kernel/core/prng.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/kernel/core/prng.c') diff --git a/src/kernel/core/prng.c b/src/kernel/core/prng.c index dbffba5..77dff7d 100644 --- a/src/kernel/core/prng.c +++ b/src/kernel/core/prng.c @@ -11,6 +11,8 @@ static const uint32_t a = 16807; static const uint32_t m = 0x7FFFFFFF; uint16_t prng_word() { + int st = enter_critical(CL_NOINT); + if (++n >= 100) { n = 0; if (entropy_count) { @@ -18,7 +20,12 @@ uint16_t prng_word() { } } x = (x * a) % m; - return x & 0xFFFF; + + uint16_t ret = x & 0xFFFF; + + exit_critical(st); + + return ret; } void prng_bytes(uint8_t* out, size_t nbytes) { -- cgit v1.2.3