From 4827fd71b4fbaec9df9529a468d815eee306a12a Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 7 Dec 2018 14:27:46 -0800 Subject: [PATCH] fusee: Fix race condition involving volatile reads --- fusee/fusee-secondary/src/smmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fusee/fusee-secondary/src/smmu.c b/fusee/fusee-secondary/src/smmu.c index 23bd3d37d..db54e5d9d 100644 --- a/fusee/fusee-secondary/src/smmu.c +++ b/fusee/fusee-secondary/src/smmu.c @@ -226,9 +226,10 @@ void smmu_emulate_tsec(void *tsec_keys, const void *package1, size_t package1_si uint32_t old_key_data = *key_data; uint32_t buf_counter = 0; while (!(tsec->FALCON_CPUCTL & 0x10)) { - if (*key_data != old_key_data) { - old_key_data = *key_data; - key_buf[buf_counter] = *key_data; + const uint32_t new_key_data = *key_data; + if (new_key_data != old_key_data) { + old_key_data = new_key_data; + key_buf[buf_counter] = new_key_data; buf_counter++; } }