Skip to content

Commit

Permalink
util: Fix coverity issue about missing lock
Browse files Browse the repository at this point in the history
All write accesses to `wait->signal` are protected by the lock. The read
access should be protected, too.

Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
  • Loading branch information
j-xiong committed Jan 19, 2024
1 parent 39e35c0 commit e16f28a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion prov/util/src/util_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,16 @@ static int util_wait_yield_run(struct fid_wait *wait_fid, int timeout)
wait = container_of(wait_fid, struct util_wait_yield, util_wait.wait_fid);
endtime = ofi_timeout_time(timeout);

while (!wait->signal) {
while (1) {
int signaled;

ofi_mutex_lock(&wait->signal_lock);
signaled = wait->signal;
ofi_mutex_unlock(&wait->signal_lock);

if (signaled)
break;

if (ofi_adjust_timeout(endtime, &timeout))
return -FI_ETIMEDOUT;
ofi_mutex_lock(&wait->util_wait.lock);
Expand Down

0 comments on commit e16f28a

Please sign in to comment.