summaryrefslogtreecommitdiff
path: root/tests/runtime_services
diff options
context:
space:
mode:
authorRoberto Vargas <roberto.vargas@arm.com>2017-09-01 10:42:32 +0100
committerRoberto Vargas <roberto.vargas@arm.com>2017-09-01 10:42:32 +0100
commitad1ed6053174b8255c947d23007c0a36ceb499fd (patch)
tree140128d426f572339e4c0f694fba722625ebd292 /tests/runtime_services
parent44e21f34a5c12634952ad1673608e694b1fcbe5e (diff)
Avoid race condition in test_psci_on_off_suspend_stress
temp_count was set to the value of cpu_on_count out of the spin_lock section, and this value was used to detect that some other cpu entered in the test. Since the value of cpu_on_count could be incremented by other cpu between spin_unlock and setting temp_count the last two cpus could enter in an infinite loop. Change-Id: Ia426af21ba17b10c8f52e660db80823ff3e9fa7c
Diffstat (limited to 'tests/runtime_services')
-rw-r--r--tests/runtime_services/standard_service/psci/system_tests/test_psci_on_off_suspend_stress.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/runtime_services/standard_service/psci/system_tests/test_psci_on_off_suspend_stress.c b/tests/runtime_services/standard_service/psci/system_tests/test_psci_on_off_suspend_stress.c
index 12c3892..2d71b30 100644
--- a/tests/runtime_services/standard_service/psci/system_tests/test_psci_on_off_suspend_stress.c
+++ b/tests/runtime_services/standard_service/psci/system_tests/test_psci_on_off_suspend_stress.c
@@ -480,11 +480,9 @@ static test_result_t launch_cpu_on_off_stress(void)
int ret;
spin_lock(&counter_lock);
- ++cpu_on_count;
- spin_unlock(&counter_lock);
-
/* Store the count in a temporary variable */
- temp_count = cpu_on_count;
+ temp_count = ++cpu_on_count;
+ spin_unlock(&counter_lock);
if (exit_test)
return TEST_RESULT_SUCCESS;