From 1635746a9c98052654318aeb9402c93081a04206 Mon Sep 17 00:00:00 2001 From: Sunday Clement Date: Thu, 29 May 2025 20:25:57 -0400 Subject: [PATCH] rocr: Fix Potential Deadlock Moved the Call to pthread_mutex_lock to an else statement for better code readibility. Signed-off-by: Sunday Clement --- runtime/hsa-runtime/core/util/lnx/os_linux.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp index da82175184..c6d90f7657 100644 --- a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp +++ b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp @@ -574,12 +574,11 @@ int WaitForOsEvent(EventHandle event, unsigned int milli_seconds) { // Timeout return 1; } + } else { + pthread_mutex_lock(&eventDescrp->mutex); } int ret_code = 0; - if(milli_seconds != 0) { - pthread_mutex_lock(&eventDescrp->mutex); - } if (!eventDescrp->state) { if (milli_seconds == 0) {